dynamic_programming.max_non_adjacent_sum

Functions

maximum_non_adjacent_sum(→ int)

Find the maximum non-adjacent sum of the integers in the nums input list

Module Contents

dynamic_programming.max_non_adjacent_sum.maximum_non_adjacent_sum(nums: list[int]) int

Find the maximum non-adjacent sum of the integers in the nums input list

>>> maximum_non_adjacent_sum([1, 2, 3])
4
>>> maximum_non_adjacent_sum([1, 5, 3, 7, 2, 2, 6])
18
>>> maximum_non_adjacent_sum([-1, -5, -3, -7, -2, -2, -6])
0
>>> maximum_non_adjacent_sum([499, 500, -3, -7, -2, -2, -6])
500