Start by clarifying the problem and edge cases, then explain that this is a classic dynamic programming problem where you decide to rob or skip each house based on the maximum of the previous two states. Walk through a simple example, derive the recurrence relation, and implement an efficient solution with O(n) time and O(1) space.
Pro tip: After presenting the optimal solution, mention that this problem is equivalent to finding the maximum sum of non-adjacent elements, and briefly discuss how you would handle variations like a circular street or negative values to show depth.
Confirm that houses are in a line, each has a non-negative amount, and you cannot rob adjacent houses. Ask about edge cases like empty input or single house.
Let dp[i] be the maximum amount robbable from the first i houses. Then dp[i] = max(dp[i-1], dp[i-2] + money[i-1]).
Use a small example like [2,7,9,3,1] to demonstrate how the recurrence builds up the solution step by step.
Observe that only the last two dp values are needed, so reduce space complexity from O(n) to O(1) by keeping two variables.
Write clean code, handle edge cases, and test with the example and additional cases like all zeros or alternating high values.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.