Problem. Houses along a street hold nums[i] money. Robbing two adjacent houses triggers an alarm. Return the maximum
amount you can rob.
nums = [1, 2, 3, 1] → 4 (houses 0 and 2)
nums = [2, 7, 9, 3, 1] → 12 (houses 0, 2 and 4)
Each house is a take or skip decision, and taking house i rules out house i − 1. That makes the best total up to i depend only on the best totals up to i − 1 and i − 2.
ML context. "Choose items to maximise value, but never two neighbours" models redundancy: picking frames from a video for annotation (adjacent frames are near-duplicates), selecting checkpoints to evaluate when consecutive ones are too similar, or scheduling jobs that can't run on adjacent time slots. With general overlap instead of adjacency it becomes weighted interval scheduling (Change C).