FDEInterviews logo
Coding & DSA / 76
mediumAmazonGoogle

House robber: max sum you can take from a row of houses without hitting two adjacent ones

The classic linear DP. At each house you either skip it and keep the best so far, or take it and add the best from two back. The signal is collapsing the table to two rolling variables and then handling the circular follow-up cleanly.

Updated Aug 2026 · Grounded in real Forward Deployed Engineer interview loops and written to a senior-engineer editorial bar.

The classic linear DP. At each house you either skip it and keep the best so far, or take it and add the best from two back. The signal is collapsing the table to two rolling variables and then handling the circular follow-up cleanly.

20 answers per topic instead of 10, plus saved progress and bookmarks · no cardor unlock all 528 remaining answers · ₹2,000 / $25
UP NEXT ON YOUR JOURNEY
FEDITOR'S NOTE

Interviewers expect the O(1)-space version once you have the recurrence. The real differentiator is House Robber II: a circular street where the first and last house are now adjacent. Candidates who try to special-case the wrap-around with conditionals usually tie themselves in knots. The clean move is to run the linear solver twice on two slices and take the max.

DISCUSSION · 0

No comments yet — be the first to share your approach.