Objective
A street has houses with money and you cannot rob two adjacent houses. At each house you decide: rob it (adding to what you had two houses back) or skip it (keeping what you had). It is dynamic programming with just two values of memory.
Instructions
- Read a line with the money in each house (non-negative integers).
- Show
Maximum loot: xwith the maximum that can be obtained.
2 7 9 3 1
Maximum loot: 12
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise