nums[i] is the money in house i. You may rob any houses, but never two neighbouring houses. Return the largest total you can take.
For [2, 7, 9, 3, 1] the answer is 12 (rob 2, 9 and 1).
The starter code tries both choices for every house. It is correct but too slow for many houses.
Example 1
Input:
rob([1, 2, 3, 1])
Output:
4
Example 2
Input:
rob([2, 7, 9, 3, 1])
Output:
12
0 <= len(nums) <= 10000000 <= nums[i] <= 10000No results yet
Run your code to check it against the examples, or submit to run every test.