Add sliding-window module: 12 sliding window and two-pointer interview problems, brute-force cross-checks, dry-run traces, operation counts, pitfalls (11 tests)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b6EqSkUWKNBc8i3Q3U
This commit is contained in:
2026-11-09 08:40:07 +00:00
co-authored by Claude Sonnet 5.5
parent 4a9021d936
commit 911aef5515
26 changed files with 1600 additions and 0 deletions
@@ -0,0 +1,24 @@
Operation counts, brute force vs window / two pointers (counted, not timed)
===========================================================================
Max sum of k=100 consecutive elements: element reads
n brute force sliding window ratio
1000 90,100 1,900 47.4x
2000 190,100 3,900 48.7x
4000 390,100 7,900 49.4x
8000 790,100 15,900 49.7x
Pair search, target absent (worst case) in a sorted array 0..n-1: checks / steps
n all pairs two pointers
1000 499,500 999
2000 1,999,000 1,999
4000 7,998,000 3,999
8000 31,996,000 7,999
minWindow on random strings over A-D, t="ABCD" (seed 42): pointer moves
The loop is nested but each pointer only moves forward, so total moves stay linear.
n right moves left moves valid windows
1000 1,000 996 996
2000 2,000 1,996 1,996
4000 4,000 3,996 3,996
8000 8,000 7,993 7,993