CodingDojo icon indicating copy to clipboard operation
CodingDojo copied to clipboard

Maximum Non-Adjacent Number Sum

Open drkennetz opened this issue 4 years ago • 2 comments

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

drkennetz avatar Jan 18 '22 23:01 drkennetz

hi please assign this to me.

HarshAggarwal1 avatar Oct 27 '22 15:10 HarshAggarwal1

Setup completed in #404 and mob solution completed in #405

xanderyzwich avatar Jan 09 '24 21:01 xanderyzwich