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

Lesson 4.3 of 10 in this module Unrolled Pro

Longest Substring Without Repeating Characters

The longest run of distinct characters. From checking every substring (O(n³)), to one set per start (O(n²)), to a sliding window with a set, to a window that jumps its left edge using each character's last position. Then at most k copies of each character, a fixed alphabet, and spotting repetition loops in generated text.

about 10 min 5 Python examples 2 quick checks

Problem. Return the length of the longest substring of s with no repeated characters.

text
"abcabcbb"   →   3     ("abc")
"bbbbb"      →   1     ("b")
"pwwkew"     →   3     ("wke"; "pwke" is a subsequence, not a substring)
""           →   0

ML context. The window pattern here, "the longest stretch with no repeats", is how you measure repetition in generated text: a language model stuck in a loop produces short repeat-free stretches, and decoders apply repetition penalties or n-gram blocking to stop it. The same window finds the longest run of unique events in a user session, or the longest stretch of a feature without duplicates.


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 "Longest Substring Without Repeating Characters"

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