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

Lesson 4.5 of 10 in this module Unrolled Pro

Permutation in String

Does s2 contain some rearrangement of s1 as a substring? From generating permutations (factorial), to sorting every window, to a fixed window of letter counts compared in O(26), to an O(1)-per-step 'matches' counter. Then returning every match, a large alphabet, and finding token spans whose bag of words matches a query.

about 10 min 4 Python examples 2 quick checks

Problem. Return True if some permutation of s1 appears as a contiguous substring of s2.

text
s1 = "ab",  s2 = "eidbaooo"   →   True      ("ba" at index 3)
s1 = "ab",  s2 = "eidboaoo"   →   False

ML context. "A window whose bag of items equals a target bag" is a span-matching problem: find the spans of a token stream that contain exactly a query's words in any order (bag-of-words matching), or the time windows whose event-type counts match a known pattern. The fixed-window count is the same structure a feature pipeline uses for "counts of each event type in the last N events".


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 "Permutation in String"

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