-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Labels
proposed challengeAn idea for a future challengeAn idea for a future challenge
Description
Maximum Non-Adjacent Number Sum
Write a function that takes in an array of positive integers and returns the maximum sum of non-adjacent elements in the array.
If the input array is empty, the function should return 0.
Business Rules/Errata
- The function takes in an array of integers
- The array is one dimensional and is not sorted
- if the array is empty, return 0
- when considering the maximum sum, integers in the array MUST be non-adjacent
- Optimal Space and Time Complexity: O(n) time | O(1) space - where n is the length of the input array
Examples
array = [75, 105, 120, 75, 90, 135]
MaxNonAdjacentSum(array) -> 330 // 75 + 120 + 135
xanderyzwich, drkennetz and HarshAggarwal1
Metadata
Metadata
Assignees
Labels
proposed challengeAn idea for a future challengeAn idea for a future challenge