r/DailyCodingProblem • u/T4ll1n • Apr 06 '22
Daily Coding Problem: Problem #9 [Hard] - 2022-04-04
Good morning! Here's your coding interview problem for today.
This problem was asked by Airbnb.
Given a list of integers, write a function that returns the largest sum of non-adjacent numbers. Numbers can be 0 or negative.
For example, [2, 4, 6, 2, 5] should return 13, since we pick 2, 6, and 5. [5, 1, 1, 5] should return 10, since we pick 5 and 5.
Follow-up: Can you do this in O(N) time and constant space?
1
Upvotes
View all comments
1
u/T4ll1n Apr 06 '22
I did not manage to get a solution that is working. Here is my attempt.