House Robber
Medium
LC #198
take or skip1d dpNot attempted yet
nums[i] is the money in house i along a street. Robbing
two adjacent houses sets off an alarm. Return the most
money you can take without triggering it.
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
houses 0, 2, 4: 2 + 9 + 1
Example 3
Input: nums = [2, 1, 1, 2]
Output: 4
houses 0 and 3
Constraints
- 1 ≤ len(nums) ≤ 1000
- 0 ≤ nums[i] ≤ 1000