← All problems

House Robber

MediumDP

You're a robber on a street of houses. You can't rob two adjacent houses. Given the loot in each house, what's the max you can rob?

Examples

Input: [1,2,3,1]
Output: 4
Houses 0 and 2: 1 + 3
Input: [2,7,9,3,1]
Output: 12
Houses 0, 2, 4: 2 + 9 + 1

Hints

Solution

Language:
Loading editor…
Output0 lines
Run your code to see output here.
Click Run all tests to check your solution against 5 test cases.