Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

<< [09] Largest sum of non-adjacent numbers >>

Given a list of integers, write a function that returns the largest sum of non-adjacent numbers. The "largest sum of non-adjacent numbers" is the sum of any subset of non-contiguous elements.

Examples:

>>> coding_problem_09([2, 4, 6, 8])
12

>>> coding_problem_09([5, 1, 1, 5])
10

>>> coding_problem_09([1, 2, 3, 4, 5, 6])
12

>>> coding_problem_09([-8, 4, -3, 2, 3, 4])
10

>>> coding_problem_09([2, 4, 6, 2, 5])
13