Techniques
Patterns that turn quadratic solutions into linear ones: two pointers, sliding windows, and memoized recursion.
Pages in this Section
- Recursion Memoization — Memoization caches the result of each unique recursive call so repeated subproblems aren't recomputed. It turns exponential naive recursion into polynomial dynamic programming with one decorator.
- Sliding Window — The sliding-window technique maintains a contiguous range over a sequence, expanding and shrinking it as you scan ā turning many O(n²) substring/subarray problems into O(n). The dual of the…
- Two Pointer — The two-pointer technique walks two indices through a sequence ā usually one at each end, or both moving forward at different speeds ā to solve problems in O(n) that look like they need…
‹ Algorithms