You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. The only constraint stopping you from robbing each of them is that adjacent houses have security systems connected - it will automatically contact the police if two adjacent houses were broken into on the same night.
Given an integer array nums representing the amount of money of each house, return the maximum amount of money you can rob tonight without alerting the police.
Recurrence Relation: dp[i] = max(dp[i-1], dp[i-2] + nums[i])
At each house, you decide: skip it (take previous max) or rob it (take value + max from two houses back).
nums = [1,2,3,1]4nums = [2,7,9,3,1]12nums = [2,1,1,2]41 <= nums.length <= 1000 <= nums[i] <= 400Click "Run" to execute your code against test cases
Socratic guidance - I'll ask questions, not give answers