FDEInterviews logoFDE/Interviews
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.

Unlock the other 466 answers · ₹2,000 / $25Your progress and mastery stay saved · 6 months · one payment · no auto-renew
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.