Showing Posts From

Patterns

Advanced Linked List, Stack & Queue

Advanced Linked List, Stack & Queue

Week 21 notes: the harder linear-structure problems, where the trick is usually combining two structures. Reversing in k-groups, monotonic deques for sliding-window max, and the LRU cache.

Hashing & Prefix Sum Patterns

Hashing & Prefix Sum Patterns

Week 20 notes: prefix sums plus a hash map is one of the combos I use most. O(1) range queries, counting subarrays with a target sum in one pass, 2-D prefix sums, and the difference array.

Two Pointers & Sliding Window (Advanced)

Two Pointers & Sliding Window (Advanced)

Week 19 notes: Phase 2 kicks off by pushing the two most reused array patterns to medium/hard. Variable windows with a shrink rule, the at-most/exactly counting trick, and multi-pointer partitioning.

Two Pointers Algorithm - Intuition & Patterns

Two Pointers Algorithm - Intuition & Patterns

Week 0 notes on the two pointers technique: the 'squeeze' idea that kills a lot of nested loops, the two movement styles, and when to actually use it.

Sliding Window Algorithm - Fixed & Variable Length

Sliding Window Algorithm - Fixed & Variable Length

Week 0 notes on the sliding window: when to use it, fixed vs variable windows, and how it turns a lot of subarray and substring problems from O(n^2) into O(n).