House Robber
House Robber
You are a professional robber planning to rob houses along a street. Each house has a non‑negative amount of money. You cannot rob adjacent houses. Return the maximum amount you can rob.
Function signature
func HouseRobber(nums []int) int
Example
nums = [2,7,9,3,1]
output = 12
Constraints
- 0 <= len(nums) <= 200_000
- 0 <= nums[i] <= 1_000_000
Notes
- Use DP: dp[i] = max(dp[i-1], dp[i-2] + nums[i]).
Run tests to see results
No issues detected