Company: Virtusa..._11oct
Difficulty: medium
Frog in the Pond Problem Description Near your house there is a pond with N lily pads arranged in a row, numbered 1 to N . The integer array A gives the number of fresh petals that have fallen on each pad: pad i holds A[i] petals. A happy frog wants to gather as many petals as possible. It may start on any lily pad it likes, and from its current pad it can jump only to the next adjacent pad, in either direction (from pad i to pad i - 1 or pad i + 1 ). The frog can make at most N - 2 jumps . Whenever the frog is on a pad, it collects all the petals on that pad, and this includes the pad it starts on. A pad's petals can be collected only once: after the frog takes them, landing on that pad again adds nothing. (inferred -- the source says the frog collects all the petals on a pad it lands on, so the pad is then empty) Find the maximum number of petals the frog can collect using at most N - 2 jumps. Complete the function maxPetals with the following parameters: N : an integer, the number o