Blog
Patterns, problems,
explained to stick.
Deep dives on the problems people keep forgetting — explanation first, code second, Big-O defended.
FeaturedSliding Window
Minimum Window Substring, without the hand-waving
The "shrink from the left" step is where everyone gets vague. Here's the invariant that makes it obvious — and the two-counter trick that keeps it O(n).
Jul 2, 2026·3 min read
while right < len(s):
window[s[right]] += 1
# invariant: window covers t
while have == need:
shrink(left) # ← the whole trickHash Map
Two Sum is not an easy problem
Everyone memorizes the answer. Almost nobody can defend the collision worst case. What "amortized O(1)" actually commits you to.
Jun 27, 2026·3 min read
DP · 1DKadane's, derived from scratch in four lines
Stop memorizing max(cur + n, n). Derive it from the "best subarray ending here" framing and you'll never blank on it again.
Jun 20, 2026·2 min read