41. House Robber
MediumDynamic programming
nums[i] is the money in house i along a street. You cannot take from two adjacent houses. Return the maximum total you can collect.
Example 1
Input: nums = [2, 7, 9, 3, 1] Output: 12 Explanation: 2 + 9 + 1
Example 2
Input: nums = [1, 2, 3, 1] Output: 4
Constraints
1 ≤ nums.length ≤ 100