VFlash: Fast, Accurate Visual Planning via Flash Primitive Decoding
u_Unrolled
DSA for AI/ML · Module 14: Greedy and intervals

Lesson 14.5 of 6 in this module Unrolled Pro

Jump Game

From index i you can jump forward up to nums[i] steps; can you reach the last index? From trying every jump recursively (exponential), to a DP marking each index reachable or not (O(n²)), to one greedy pass that tracks the farthest index reachable so far (O(n), O(1) space). Then the fewest jumps, solved greedily as BFS levels, jumps in both directions (BFS on a graph), landing costs (DP), and choosing the fewest keyframes to process in a video.

about 10 min 3 Python examples 2 quick checks

Problem. nums[i] is the maximum jump length from index i. Starting at index 0, return whether you can reach the last index.

text
nums = [2, 3, 1, 1, 4]   →   True     (0 → 1 → 4)
nums = [3, 2, 1, 0, 4]   →   False    (every path gets stuck on the 0 at index 3)

It looks like a search over jump choices, and it is one. But reachability has a special shape: if you can reach index j, you can reach every index before j too (jump shorter). So the set of reachable indices is always a prefix [0, reach], and the whole question is how far reach gets.

ML context. The fewest-jumps version (Change A) chooses the fewest keyframes to process in a video: if frame i's features stay valid for the next nums[i] frames (the scene doesn't change), the fewest frames that cover the whole video is the minimum number of jumps (Change D). The same "farthest reach" greedy plans checkpoints, cache refreshes and sampled evaluations over a sequence.


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 "Jump Game"

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