VFlash: Fast, Accurate Visual Planning via Flash Primitive Decoding
u_Unrolled
DSA for AI/ML · Module 03: Two pointers

Lesson 3.7 of 10 in this module Unrolled Pro

Container With Most Water

Pick two walls that hold the most water. From checking every pair, to converging pointers that always move the shorter wall, with the proof of why the shorter wall can be discarded. Then a minimum gap, returning the walls, the histogram look-alike that needs a stack, and the bound-and-prune idea behind the proof.

about 10 min 3 Python examples 2 quick checks

Problem. height[i] is the height of a vertical wall at position i. Choose two walls i < j; together with the x-axis they hold water with area (j − i) × min(height[i], height[j]). Return the maximum area.

text
height = [1, 8, 6, 2, 5, 4, 8, 3, 7]   →   49     (walls at 1 and 8: width 7 × height 7)
height = [1, 1]                        →   1

ML context. The useful part isn't water: it's the proof technique. When an objective is limited by the smaller of two parts (a bottleneck), you can discard the limiting part once you've scored it, because no other choice can help it. The same "bound, then prune" reasoning powers early stopping in hyperparameter search and pruning in nearest-neighbour search: skip whatever provably can't beat the best answer so far.


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 "Container With Most Water"

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