Real engineering thinking — the algorithms, trade-offs, and lessons behind the code we write.
A deceptively simple geometry problem, a division-based solution that fails at test case 64, and the cross-multiplication trick that fixes it.
August 10, 2026 · 3 min read
Range queries over an array are the most common 'is my solution fast enough' trap. Prefix sums turn them into O(1) lookups.
August 5, 2026 · 2 min read
Count zeros on the left, ones on the right, and sweep once. The trick is a running score that updates as the split point moves.
August 1, 2026 · 2 min read
Instead of tracking both halves, compute the total once and derive the right side from the left. One pass, constant space.
July 28, 2026 · 2 min read
A frequency map turns 'find the longest subsequence with values differing by exactly 1' into a few map lookups.
July 22, 2026 · 2 min read
Two classic traversals, one goal: the maximum per level. BFS processes rows naturally; DFS tracks depth explicitly.
July 16, 2026 · 2 min read
Make the most significant column all ones, then maximize each remaining column independently. Greedy works because choices don't interfere.
July 10, 2026 · 2 min read
Sort by wage-to-quality, keep the k smallest qualities, and sweep. The subtle part is *when* you pop the heap.
July 4, 2026 · 4 min read
Leaf pairs whose distance is within a limit. The naive path-strip works; a DFS that passes leaf-distance counts up the tree is the clean win.
June 27, 2026 · 3 min read
Consecutive days with prices below today? A stack of (price, span) pairs answers each next() in amortized O(1).
June 20, 2026 · 2 min read
Link every node to its right neighbor. A single recursive pass that processes right children first makes the 'next' pointer trivially available.
June 14, 2026 · 2 min read