181. House Robber

A professional robber cannot rob two adjacent houses. Given an array of amounts in the houses, return the maximum amount without robbing adjacent houses.
Example 1
Input: nums = [2,7,9,3,1]
Output: 12
Explanation: Optimal: 2 + 9 + 1 = 12.
Example 2
Input: nums = [1,2,3,1]
Output: 4
Explanation: Rob houses 1 and 3: 1 + 3 = 4.
arraysdynamic programmingmedium
JavaScript
Loading...
Line 1, Char 1