Glossary

Coding-interview glossary.

Short, citation-ready definitions for the 12 canonical patterns. Each entry is structured for quick lookup: definition, complexity, one scenario, and a link to the full pattern page.

Sliding WindowMaintain a contiguous range and slide its boundaries to avoid recomputation.Two PointersTwo cursors moving independently over a sorted or monotone structure.Monotonic StackA stack whose elements stay in non-increasing or non-decreasing order.Prefix & SuffixPrecompute cumulative arrays so range queries answer in O(1).Binary Search on AnswerWhen a predicate is monotonic over the answer space, binary search the answer itself.Heap & Priority QueueA data structure that returns the min or max in O(log n) per operation.Union-Find (DSU)A disjoint-set data structure supporting near-constant merge and find.Topological SortLinear ordering of a DAG consistent with its dependencies.Graph BFS / DFSBreadth-first for shortest unweighted paths; depth-first for exhaustive traversal.Dynamic ProgrammingBreak an overlapping-subproblem problem into a recurrence and cache results.BacktrackingDFS through a decision tree with pruning and state restoration.Interval SweepSort events by time, sweep a line, maintain an active set for overlap questions.