medium
House Robber
Houses along a street hold given amounts of money. Robbing two adjacent houses trips an alarm. Return the maximum amount you can steal without robbing two neighbours.
Constraints
- 1 ≤ n ≤ 100
- 0 ≤ nums[i] ≤ 400
Examples
in: nums = [2,7,9,3,1]
out: 12
Rob houses 1, 3 and 5.
Code it yourself
Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?
Choose an approach to check your pattern recognition, or reveal the discussion when you need help.