Skip to content
GKgkml.dev
← Pattern lab

Interview problem set 🐍

The problems that recur across every "most asked" list, grouped by the pattern they teach rather than by number. Each one gives you the tell that identifies it, the reasoning in the order you would actually derive it, the complexity, a working Python solution, and the mistake that most often costs the offer.

problems
81
patterns
14
easy
19
medium
51
hard
11

Arrays & hashing

Trade memory for time. If a nested loop is re-answering the same lookup, a dict or set collapses it to one pass.

Two pointers

Sorted or monotone input, and you need a pair, a partition, or an in-place rearrangement.

Sliding window

A contiguous range with a constraint — longest, shortest, or at most k of something.

Stack & monotonic stack

Matching pairs, or 'next greater / previous smaller' where a nested scan looks unavoidable.

Binary search

Sorted data, or a monotone feasibility predicate you can search over instead of the array.

Linked lists

Pointer surgery. Dummy heads remove edge cases; fast and slow pointers find cycles and midpoints.

Trees & BST

Recursion that returns something useful from each subtree, or an in-order walk that must be sorted.

Tries

Prefix queries over a set of strings, where lookup should cost the word length rather than the dictionary size.

Heaps & top-k

You need the k best, a running median, or repeated access to the current minimum.

Backtracking

Enumerate every valid configuration — subsets, permutations, placements — pruning as early as possible.

Graphs

Grids and dependencies. BFS for fewest steps, DFS for structure, topological sort for ordering.

Dynamic programming

Overlapping subproblems with optimal substructure. Name the state before you write any code.

Greedy & intervals

A local choice that is provably safe, or intervals that become tractable once sorted.

Bit manipulation & math

XOR cancellation, low-bit tricks, and problems where the arithmetic is the algorithm.