You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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
Examples
The text was updated successfully, but these errors were encountered: