Learn
Practice
Newsletter
Resources
Animations
New
F
Toggle theme
0
F
0
Toggle menu
← Back to All Animations
House Robber
Bookmark
Input
Example 1
Example 2
Example 3
Adjacent pattern
Single house
Two houses
Custom
nums
=
[2, 7, 9, 3, 1]
2
?
0
7
?
1
9
?
2
3
?
3
1
?
4
dp
dp[i] = max(dp[i-1], dp[i-2] + nums[i])
algo
master
.
io
Step:
Start: rob houses for maximum loot without hitting two adjacent ones
0 / 9
Input
Example 1
Example 2
Example 3
Adjacent pattern
Single house
Two houses
Custom
nums
=
[2, 7, 9, 3, 1]
0 / 9
2
?
0
7
?
1
9
?
2
3
?
3
1
?
4
dp
dp[i] = max(dp[i-1], dp[i-2] + nums[i])
algo
master
.
io
Step:
Start: rob houses for maximum loot without hitting two adjacent ones