The Blind 75 Leetcode Series: House Robber

Jonathan Chao
3 min readOct 5, 2022
Photo by Chris Ried on Unsplash

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:

  1. What is the number of houses in this question? Do we have an hypothetical, endless street?
  2. Do we ever expect the sum to be out of range of, say, a 32-bit int?
  3. We are not expecting negative numbers, correct? (since we are dealing with money)

--

--

Jonathan Chao

I am a software developer who has been in this industry for close to a decade. I share my experience to people who are or want to get into the industry