tourism is planning to construct a park and install water fountains. It is planning to organize "Musical Fountain" shows. The fountains shoot water in air in varying directions and with varying heights. Fountains are to be installed in a row such that water from all the fountains is visible.
You are given int [ ] height, int [ ] turnOnTime, and int [ ] turnOffTime. height represents how high each fountain shoots water in air, turnOnTime represents the time when fountain shoots the water in air and turnOffTime represents the time when fountain stops shooting the water. Musical fountain show would be for 30 minutes. Elements in turnOnTime and turnOffTime will be a number between 1 and 30 inclusive and turnOffTime [ i ] will always be greater than turnOnTime [ i ]. Fountain that shoots water high in air is to be installed as far as possible. The fountain that shoots water with less height must be installed in front of the fountain that shoots water high in air to prevent blocking. A fountain can start shooting water and other stops at the same minute but still one can block the other. You should also try to have the fountain with maximum possible height being first in the park. You should return a int[ ] which contains the elements of height in the order you should install fountains to achieve the above goal. The front of the park is represented by the first element in your return value, and is where you view the fountains from. The elements in height [ ] will all be unique *Definition:* Class: MusicalFountain Method: getFountainOrdering Parameters: int [ ] , int [ ] , int [ ] Returns: int [ ] Method signature: int [ ] getFountainOrdering (int [ ] height, int [ ] turnOnTime, int [ ] turnOffTime) (be sure your method is public) *Constraints:* - height will have between 2 and 10 unique elements, inclusive. - turnOnTime and turnOffTime will have the same number of elements as height. - Each element of height will be between 1 and 30 meters, inclusive. - Each element of turnOnTime and turnOffTime will be between 1 and 30 minutes, inclusive. - For each element i of turnOnTime and turnOffTime, turnOffTime [ i ] will be greater than turnOnTime [ i ]. *Examples * *(1)* height [ ] = {6, 5, 4, 3, 2, 1} turnOnTime [ ] = {1, 1, 1, 1, 1, 1} turnOffTime [ ] = {30, 30, 30, 30, 30, 30} Returns: {1, 2, 3, 4, 5, 6} All fountains start at 1st minute and stop at 30th minute. All will block each other; you must order them from shortest to tallest. *(2)* height [ ] = {6, 5, 4, 3, 2, 1} turnOnTime [ ] = {1, 5, 10, 15, 20, 25} turnOffTime [ ] = {4, 9, 14, 19, 24, 29} Returns: {6, 5, 4, 3, 2, 1} The fountains start and stop at different times so they will never block each other. You can order them from tallest to shortest. *(3)* height [ ] = {6, 5, 4, 3, 2, 1} turnOnTime [ ] = {1, 5, 10, 15, 20, 25} turnOffTime [ ] = {5, 10, 15, 20, 25, 30} Returns: {1, 2, 3, 4, 5} Each fountain only blocks at most one other, they all must be ordered from shortest to tallest to prevent any blocking. *(4)* height [ ] = {6, 5, 4, 3, 2, 1} turnOnTime [ ] = {1, 5, 10, 15, 20, 25} turnOffTime [ ] = {5, 10, 12, 20, 25, 30} Returns: {4, 5, 6, 1, 2, 3} Here the 3rd fountain is turned off 3 minutes before the 4th fountain is turned on. Therefore, we can put the fountain of height 4 first, then height 5, then height 6 and finally the fountains of height 1, 2 and 3. We could have also installed them with height 1 first, but this does not result in the maximum possible height being first in the park. -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-code/-/zgrqVzP_A9kJ. To post to this group, send email to google-code@googlegroups.com. To unsubscribe from this group, send email to google-code+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-code?hl=en.