📎 Webclip
14 Patterns to Ace Any Coding Interview Question
The article argues that coding interview prep becomes easier when questions are mapped to recurring patterns rather than treated as hundreds of separate problems. It presents 14 patterns, each with cues for recognition and example problem types, and recommends deeper practice through the linked course.
Reading notes#
- Sliding Window applies to linear inputs like arrays, linked lists, or strings when the task is to find a longest or shortest substring, subarray, or target value.
- Two Pointers is described as a way to scan sorted arrays or linked lists in tandem, especially for pairs, triplets, or subarrays.
- Fast and Slow pointers use different speeds through a list or array to handle cycles and some position or length questions.
- Merge Intervals is used for overlapping intervals and for producing a list of mutually exclusive intervals.
- Cyclic sort handles arrays with numbers in a given range by moving each number toward its correct index.
- In-place reversal of a linked list is used when the list must be reversed without extra memory.
- Tree BFS traverses a tree level by level with a queue.
- Tree DFS traverses a tree with recursion or a stack using preorder, inorder, or postorder.
- Two heaps split a set into two parts when the task is to track smallest, biggest, or median values.
- Subsets covers combinations and permutations by expanding all current subsets for each new element.
- Modified binary search applies to sorted arrays, linked lists, or matrices when searching for a target efficiently.
- Top K elements uses a heap to keep track of the largest, smallest, or most frequent K items.
- K-way Merge uses a heap to merge sorted arrays or lists in order.
- Topological sort orders elements with dependencies by building the graph, finding zero in-degree sources, and processing them in queue order.
