Robbing a street
Mediumdynamic programmingarray
Houses stand in a row and nums[i] is the money in house i. You can't take from two adjacent houses. Return the maximum amount possible.
Example 1
Input: nums = [1,2,3,1] Output: 4
Houses 0 and 2: 1 + 3.
Example 2
Input: nums = [2,7,9,3,1] Output: 12
Constraints
- 1 ≤ nums.length ≤ 100
- 0 ≤ nums[i] ≤ 400
Submit checks your solution against 8 tests, including hidden ones.
/**
* @param {int[]} nums
* @return {int}
*/
function rob(nums) {
}