VFlash: Fast, Accurate Visual Planning via Flash Primitive Decoding
u_Unrolled
DSA for AI/ML · Module 12: Dynamic programming

Lesson 12.3 of 16 in this module Unrolled Pro

House Robber

Pick values from a row to maximise their sum without taking two neighbours. From trying every subset with no two adjacent (exponential), to the take-or-skip recurrence best(i) = max(best(i − 1), best(i − 2) + value[i]) in O(n) time and O(1) space, plus recovering which items were taken. Then a circular row (two linear runs), a tree of houses (return a pair per subtree), weighted intervals that conflict when they overlap, and the ML use: choosing which evaluation runs or frames to keep when neighbours are redundant.

about 10 min 4 Python examples 2 quick checks

Problem. Houses along a street hold nums[i] money. Robbing two adjacent houses triggers an alarm. Return the maximum amount you can rob.

text
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).


1. Step 1: Clarify

That's the preview. Modules 00–01 are free; this lesson is part of Unrolled Pro.
Staff AI & Pro Tier Lesson

Unlock "House Robber"

The foundations are free forever. Unrolled Pro unlocks the complete lesson, production architectures, and 55 battle-tested ML system design case studies.

Everything included with Pro:
All 234+ Deep-Dive Lessons across transformer internals, inference, RAG & agents
55 Staff-Level ML & System Design Case Studies with mathematical capacity estimates
AI Engineer Sheet & Exercises with worked solutions, self-checks, and code
100 Landmark Research Papers guided walkthroughs & progress tracking
14-Day Money-Back Guarantee — 100% full refund if you aren't satisfied
View Plans & Unlock All Lessons

From ₹167/mo (~$2/mo) · Cancel anytime · Instant activation

100% Risk-Free: 14-day no-questions-asked money-back guarantee