VFlash: Fast, Accurate Visual Planning via Flash Primitive Decoding
u_Unrolled
DSA for AI/ML · Module 04: Sliding window

Lesson 4.8 of 10 in this module Unrolled Pro

Minimum Window Substring

The shortest substring of s that contains every character of t (with repeats). From checking every substring, to a growing scan per start, to the 'shortest valid window' template: expand until valid, then shrink while still valid, tracking how many requirements are met in O(1). Then skipping irrelevant characters, order that matters, and finding the shortest snippet that contains every query term for search results.

about 10 min 3 Python examples 2 quick checks

Problem. Return the shortest substring of s that contains every character of t, including duplicates (if t has two 'a's, the window needs at least two). Return "" if there's none.

text
s = "ADOBECODEBANC", t = "ABC"   →   "BANC"
s = "a",             t = "aa"    →   ""

ML context. Replace characters with words: "the shortest span of a document containing every query term" is how search engines and RAG interfaces choose the snippet to show (and to highlight) for a retrieved document. It's also how you find the tightest window of logs containing every event type of an incident.


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 "Minimum Window Substring"

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