Maximum Chocolates from Jars (L.C. 198 :)
There is a set of N jars containing chocolates. Some of them may be empty. Determine the maximum number of chocolates Andrew can pick from the jars given that he cannot pick from jars next to each other.
Write an algorithm to find the maximum number of chocolates that can be picked from the jars in such a way that the chocolates are not picked from jars next to each other.
Input
The first line of input consists of an integer- numJars, representing the number of jars (N).
The next line consists of N space-separated integers representing the number of chocolates in each jar.
Output
Print the maximum number of chocolates that can be picked from the jars in such a way that the chocolates are not picked from jars next to each other.
Constraints
1 ≤ N ≤ 1000
💐 spike carries! ༊·°🌺
1Example 1
Constraints
Limits and guarantees your solution can rely on.
1 ≤ N ≤ 1000