🌱 DSA (Beginner) · Core Patterns · cozy lesson
Sliding Window
12 min · 1 min read · no scary math, promise
🤖
You’ve got this. Read a little, play a little — I’ll wait. No rush.
def longest_unique(s):
seen, l, best = {}, 0, 0
for r, ch in enumerate(s):
if ch in seen and seen[ch] >= l:
l = seen[ch]+1
seen[ch] = r
best = max(best, r-l+1)
return best
💛 Enjoying? Try 5 playful quizzes or watch it move.
Check your understanding
Correct answers earn XP (once each).
1. Fixed k average?
2. Longest without repeat?
My notes (saved in this browser)
Select text above → Save selection, or write your own. AlgoMaster-style notebook, local-first for MVP.
No notes yet. Your highlights will live here.
Finished reading? Seal it with a tick ✅
The checkbox in the explorer turns green too — same progress.