Skip to main content
πŸ”’ Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial β†’
⚑
← Coursesβ€ΊInterview PrepModule 4 Β· Dynamic Programming & Heap Β· Recapβ€ΊπŸŽ― Review: Interview Prep module 4 recapscenario63 / 104
+80 XP
Task
Build the canonical House Robber DP: `dp_house_robber(amounts)` returns the max sum of non-adjacent values: - Cannot pick two indices in a row (alarm wires them together). - Empty list β†’ 0. - Single house β†’ its amount. - General: `dp[i] = max(dp[i-1], dp[i-2] + amounts[i])` β€” either skip this house or take it plus the best up-to-2-back. LeetCode #198 β€” the cleanest demonstration of "1-D DP with 2-step lookback".
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
πŸ“Š Result
Press Run to see result...

πŸ’¬ Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…