PMMockr

QuestionsTechnical PMTop-Interview

Given n houses in a line with money in each, find the maximum amount a robber can steal, without stealing from two adjacent houses.

Focus on breaking down the problem using dynamic programming principles. Start by defining the state: let `dp[i]` represent the maximum amount of money that can be stolen from the first `i` houses. Explain how to derive the recurrence relation: either the robber skips the current house and takes the maximum from the previous house (`dp[i-1]`), or robs the current house and adds its value to the maximum from two houses back (`money[i] + dp[i-2]`). Discuss the base cases and how to initialize your `dp` array. Finally, ensure you articulate the time and space complexity of your solution, and consider edge cases like an empty array or a single house.

What this question tests

Practise this question under interview conditions. Answer it out loud against a timer with an AI interviewer that asks follow-ups, then review the scored report.

Start a timed mock interview

Related Technical PM questions

All Technical PM questions · Product manager interview questions by skill area