Company: GigSky
Difficulty: medium
Watering Plants Imagine you are a park ranger responsible for maintaining N plants along a hiking trail. The plants are arranged in a straight line and numbered from 0 to N-1, with the i th plant located at x = i. You have a water source at x = -1, which you must use to refill your watering can. Each plant requires a different amount of water and you must water them in order, from left to right. If you run out of water while watering a plant, you must return to the water source to refill your watering can before continuing to the next plant. You cannot refill your watering can before it is empty or it cannot water the next plant. It takes one step to move one unit on the x-axis. Determine the number of steps you must take to water all of the plants along the hiking trail successfully. Notes You start at -1. The location of the plants starts from 0. Function Description Complete the function solution() provided in the editor. The function takes the following 3 parameters and returns the