Annotated solutions to interview and competitive-programming problems in Python, TypeScript, and Rust.
- Longest Common Subsequence derives the dynamic-programming recurrence from optimal substructure, then works through a complete table by hand.
- Largest Rectangle in a Histogram explains the monotonic stack in terms of the rectangles that remain possible, including the subtle meaning of each stored start index.
- Pacific Atlantic Water Flow turns the problem around: instead of tracing water downhill from every cell, it flood-fills uphill from both oceans.
- Binary Tree Maximum Path Sum uses post-order traversal to distinguish a complete path at a node from the one-sided path that can be extended by its parent.
- Two Knights develops a closed-form counting argument by subtracting the attacking configurations, found through the geometry of 2-by-3 rectangles, from all possible placements.
For a broader guide to choosing techniques, see “Is dismissing the algorithmic tech interview a memetic hazard?”.
The rest of the repository contains solutions from NeetCode, CSES, and CodeSignal.