Questions › Technical PM › Top-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.
- Technical PM
- Top-Interview
- Medium
- 10 min
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
- Technical PM
- Structured problem solving
- Communication
- Trade-off reasoning
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.
Related Technical PM questions
- Design a system to schedule jobs in a distributed environment.Top-Interview · Technical PM · Easy
- Monthly Post Success Analysis.Top-Interview · Technical PM · Easy
- Tree Node.Top-Interview · Technical PM · Easy
- Is this a valid palindrome?Top-Interview · Technical PM · Easy
- Find the first missing positive number in an array.Top-Interview · Technical PM · Easy
- Find the number of users who called three or more people in the last week.Top-Interview · Technical PM · Easy
All Technical PM questions · Product manager interview questions by skill area