The Blind 75 Leetcode Series: House Robber
Today, we are working on 198. House Robber
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 and 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.
We are back to arrays. This time we essentially want to sum up the numbers and find max with one catch: We cannot ad the adjacent numbers.
Some additional questions to ask for specifications can be:
- What is the number of houses in this question? Do we have an hypothetical, endless street?
- Do we ever expect the sum to be out of range of, say, a 32-bit int?
- We are not expecting negative numbers, correct? (since we are dealing with money)