We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Max Array Sum
- Discussions
Max Array Sum
Max Array Sum
Sort by
recency
|
492 Discussions
|
Please Login in order to post a comment
Java 8 solution (passes all test cases):
Using an additional array
def max_sum_non_adjacent(arr): if not arr: return 0 if len(arr) == 1: return arr[0]
Space complexity O(1) and time complexity O(n) Many answers here have space complexity O(n)
very straightforward dynamic programming question, O(n)