DSA · Dynamic programming · #19
House Robber
Module 22 · difficulty 3/5·⏱ 30:00starts on first keystroke
You are a robber planning to rob houses along a street. Each house has some money stashed, given by `nums`. The only constraint: adjacent houses have connected alarms, so you cannot rob two adjacent houses on the same night. Return the maximum amount of money you can rob without alerting the police.
Examples
nums = [1,2,3,1]→4— rob house 0 (1) + house 2 (3) = 4nums = [2,7,9,3,1]→12— rob houses 0 + 2 + 4 = 2+9+1nums = [5]→5
Constraints
- · 1 <= nums.length <= 100
- · 0 <= nums[i] <= 400
Session phases
A · Clarify
B · Approach
C · Complexity
D · Edges
E · Code
F · Tradeoff
G · Score
Phase A — Clarify
Ask questions about input bounds, types, and edge constraints.
Ask the coach clarifying questions about the problem.
When you've covered this phase, advance to the next.