Follow adjacency as deeply as needed to decide reachability, enumerate components, or aggregate each component. The goal is to exhaust a region, not to minimize travel distance.
Treat a matrix as an implicit graph and consume the maximal region connected to a seed, supporting recoloring, area, boundary-touch, and enclosure analysis.
Turn prerequisites into an executable order by repeatedly removing tasks with no unfinished predecessors; detect directed cycles and support execution layers or DAG DP.
Binary search and monotone answer · binary-search-answer
Avoid constructing the optimum directly; ask can(x) over candidate answers and exploit monotone feasibility to find a minimum feasible or maximum feasible value.
Pointers and sliding window · sliding-window-variable
Expand a contiguous interval on the right and move the left edge only forward, maintaining constraints incrementally to find a longest valid or shortest covering window.
Prefix, difference, and hashed state · prefix-state-hash
Rewrite a contiguous-interval condition as a relationship between the current prefix and a historical prefix, using a hash table to avoid O(n²) interval enumeration.
Prefix, difference, and hashed state · frequency-counting
Map items into a key domain and retain occurrence counts, representing a multiset rather than positions for equality, pairing, buckets, voting, and frequency-driven reconstruction.
Use a LIFO stack to preserve unfinished contexts or undoable history, making nested parsing, expression reduction, path normalization, and recursive execution explicit.
Stack and monotone deque · balanced-delimiter-stack
Validate or analyze nested delimiter types so each closer matches the most recent unmatched opener of the corresponding kind, optionally tracking positions, depth, or longest valid spans.
Keep unresolved candidate indexes monotone by value so each new item resolves every dominated candidate once, supporting nearest boundaries, spans, rectangles, and contribution counting.
Merge several internally ordered sources into one ordered stream, or consume only its global prefix. Each source exposes one unconsumed head; a heap chooses the smallest head.
Turn interval choices into an irreversible coordinate scan. Sorting by a start or finish endpoint exposes a boundary that supports maximum compatibility, minimum conflict deletion, merging, or coverage.
Derive and prove a local order: whenever adjacent decisions violate it, swapping them cannot worsen the objective. Repeating those swaps transforms an optimum into the greedy order. This is a proof discipline, not permission to sort by intuition.
Split a size-n problem into structurally identical, nearly independent subproblems, solve them recursively, and recover cross-boundary information in a controlled combine step. The design center is the returned summary, not the presence of two recursive calls.
Process a sequence by prefixes and collapse an exponential decision tree into a small family of states at position i. Each step depends only on already finalized earlier positions.
On a grid whose movement directions form a DAG, combine finalized neighboring states into the optimum or count for each cell instead of enumerating all paths.
For selections that may skip elements while preserving relative order, use a state ending at a position or relating two prefixes to compute longest, matching, or edit objectives.
Exploit a tree's acyclic hierarchy by returning a small set of boundary states from each node to its parent. Independent child subtrees then combine into selection, path, covering, or counting answers.
Backtracking and constraint search · subsets-combinations-backtracking
Enumerate set selections systematically. A start index gives every combination one canonical generation order, while a mutable path is extended and undone around each recursive call.
Backtracking and constraint search · permutation-backtracking
Construct an ordered arrangement one position at a time. A used set or in-place prefix records occupied elements, while same-level duplicate pruning avoids equivalent branches.
Backtracking and constraint search · constraint-backtracking
Find one or all assignments satisfying constraints. Assign one variable at a time, maintain local conflict summaries immediately, and undo on failure; variable/value ordering and propagation make contradictions appear early.
Use postorder so each node receives child summaries before returning only the minimal information its parent needs. At the same node, update complete global candidates that cannot be extended upward as a whole.
Expand a tree by depth with a FIFO queue. Freeze the queue length each round to process exactly one layer, enabling per-level summaries, views, and shallowest-match queries.
Exploit the BST's global order: inorder traversal is sorted, and every node inherits a value range jointly imposed by all ancestors. This supports validation, search, rank, and predecessor/successor queries.
Materialize shared string prefixes as shared paths so insertion, full-word lookup, prefix lookup, and prefix-guided DFS pruning advance only by character depth.