Largest sum of non-adjacent numbers

Question

Given a list of integers, write a function that will return the largest sum of non-adjacent numbers. Note the numbers in the list can be 0 or negative.

For example, [3, 5, 6, 9] should return 14, since we pick 5 and 9. [2, 1, 1, 2] should return 2, since we pick 2 and 2.

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now