Notes / tag / interview-patterns

#interview-patterns

18 notes

# Data Structures Algorithms

All Data Structures Algorithms notes →

1 — Two Pointers Pattern

Recognizing when a problem's brute-force nested loop collapses to a single pass with two coordinated pointers.

data-structures-algorithms interview-patterns book

10 — BFS Pattern

Recognizing shortest-path/level-order/minimum-step problems that breadth-first search solves optimally on unweighted graphs.

data-structures-algorithms interview-patterns book

11 — Tree DFS Pattern

Recognizing tree problems that reduce to a DFS template carrying a small amount of state root-to-leaf.

data-structures-algorithms interview-patterns book

12 — Graph Pattern

Recognizing problems phrased as text/grid/relationship data that are actually graph traversal or connectivity in disguise.

data-structures-algorithms interview-patterns book

13 — Dynamic Programming Pattern

Recognizing optimal-substructure-plus-overlapping-subproblems phrasing that signals memoization or tabulation over brute force.

data-structures-algorithms interview-patterns book

14 — Monotonic Stack Pattern

Recognizing next-greater/next-smaller-style problems that a monotonic stack solves in O(n).

data-structures-algorithms interview-patterns book

15 — Union Find Pattern

Recognizing dynamic-connectivity and grouping problems that Union-Find solves faster than repeated traversal.

data-structures-algorithms interview-patterns book

16 — Prefix Sum Pattern

Recognizing range-sum-query problems that precomputed prefix sums answer in O(1) per query.

data-structures-algorithms interview-patterns book

17 — Heap Pattern

Recognizing 'k-th'/'top-k'/'median-of-stream' problems that a heap (or two heaps) solves without full sorting.

data-structures-algorithms interview-patterns book

18 — Trie Pattern

Recognizing prefix-matching and autocomplete-style string problems that a trie solves faster than repeated string comparison.

data-structures-algorithms interview-patterns book

2 — Sliding Window Pattern

Recognizing when a problem is secretly asking for a variable- or fixed-size window over a sequence.

data-structures-algorithms interview-patterns book

3 — Fast & Slow Pointer

Recognizing cycle-detection and middle-of-sequence problems that Floyd's fast/slow pointer solves in O(1) space.

data-structures-algorithms interview-patterns book

4 — Binary Search Pattern

Recognizing when a search space is monotonic enough to binary search over, even when there's no literal sorted array.

data-structures-algorithms interview-patterns book

5 — Merge Intervals

Recognizing interval-overlap problems that reduce to sort-by-start-time plus a linear merge pass.

data-structures-algorithms interview-patterns book

6 — Cyclic Sort

Recognizing array problems where values are bounded 1..n and can be placed at their own index in-place.

data-structures-algorithms interview-patterns book

7 — Top K Elements

Recognizing 'k largest/smallest/most frequent' problems that a fixed-size heap solves in O(n log k).

data-structures-algorithms interview-patterns book

8 — K-way Merge

Recognizing problems over k sorted sequences that a heap-based merge solves in O(n log k) instead of a full sort.

data-structures-algorithms interview-patterns book

9 — DFS Pattern

Recognizing when exhaustive path/combination exploration is really depth-first search with backtracking.

data-structures-algorithms interview-patterns book