Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maximum Non-Adjacent Number Sum #249

Open
drkennetz opened this issue Jan 18, 2022 · 2 comments
Open

Maximum Non-Adjacent Number Sum #249

drkennetz opened this issue Jan 18, 2022 · 2 comments
Labels
proposed challenge An idea for a future challenge

Comments

@drkennetz
Copy link
Collaborator

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 drkennetz added the proposed challenge An idea for a future challenge label Jan 18, 2022
@HarshAggarwal1
Copy link

hi please assign this to me.

@xanderyzwich
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposed challenge An idea for a future challenge
Projects
None yet
Development

No branches or pull requests

3 participants