GL
GrindLens
PatternsSheetsPricingQuestions
  1. Home
  2. /Patterns
Pattern Taxonomy

Algorithmic Patterns & Solving Techniques

Technical interviews test repeatable problem-solving techniques rather than memorized solutions. Explore the canonical taxonomy of algorithmic patterns, their core intuition, and vetted practice problems.

Patterns: 84
Categories: 20
Mapped Problems: 313

Arrays

3 patterns

Array Rotation via Triple Reversal

Rotate an array in place by reversing the whole array and then reversing its two constituent segments.

1 problem
1M

Kadane's Algorithm

Track the best subarray sum ending at the current index, resetting to zero whenever the running sum turns negative.

2 problems
2M

Prefix Sum

Precompute running sums (or products) so range queries or comparisons become O(1) instead of re-scanning.

15 problems
4E9M2H

Backtracking

6 patterns

Backtracking - Combinations

Build fixed- or variable-length combinations by choosing the next element from a remaining candidate pool.

5 problems
5M

Backtracking - Grid Path Search

DFS with backtracking over a 2D grid, marking/unmarking visited cells while searching for a path matching a target.

2 problems
1M1H

Backtracking - Partition/Cut Points

Build the recursion tree by choosing where to make the next cut/partition point, rather than an include/exclude decision per element.

Binary Search

3 patterns

Binary Search (Classic Lookup)

Standard binary search over a sorted array (or a local monotonic comparison) to locate a target index or boundary.

7 problems
2E4M1H

Binary Search on a Rotated Array

Binary search adapted to a rotated sorted array by determining which half is still sorted at each step.

2 problems
2M

Binary Search on the Answer

Bit Manipulation

2 patterns

Bit Manipulation - Counting/Shifting

Count, shift, or accumulate individual bits to compute a numeric property (popcount, reversal, running totals).

6 problems
5E1M

Bit Manipulation - XOR Tricks

Use XOR's self-cancelling property to isolate a unique or missing value among duplicates.

7 problems
3E4M

Divide & Conquer

1 pattern

Divide and Conquer

Split the problem into independent subproblems, solve each recursively, and combine their results.

6 problems
1E5M

Dynamic Programming

12 patterns

0/1 Knapsack

DP where each item may be used at most once, choosing a subset that hits or approaches a target.

2 problems
2M

Circular Array DP

Handle a circular adjacency constraint by reducing to two linear DP passes that each exclude one end.

1 problem
1M

Expand Around Center

Treat every index (and gap between indices) as a palindrome center and expand outward while it still matches.

2 problems

Graphs

10 patterns

BFS Shortest Path (Unweighted)

Standard BFS where each edge has equal weight, so the first time a node is reached is guaranteed shortest.

3 problems
2M1H

Bounded-Hop Shortest Path (Bellman-Ford Style)

Relax edges for a limited number of rounds (bounding the number of hops/stops) rather than running unbounded Dijkstra, since the constraint makes plain Dijkstra unsound.

1 problem
1M

Dijkstra's Shortest Path

Priority-queue-driven shortest path on a weighted graph with non-negative edges, greedily finalizing the closest node.

Greedy

6 patterns

Boyer-Moore Voting Algorithm

Maintain a single candidate and a counter, incrementing on a match and decrementing otherwise, to find a majority element in one pass with O(1) space.

1 problem
1E

Greedy Farthest-Reach Tracking

Greedily track the farthest index reachable so far while scanning left to right to decide feasibility or minimum jumps.

2 problems
2M

Greedy Interval Scheduling

Sort intervals by end time and greedily keep/skip each one to maximize non-overlapping selections.

Hashing

3 patterns

Hashmap Existence / Complement Lookup

Use a hashmap or set purely to answer 'have I seen this before' or 'does the complement exist', not to count occurrences.

6 problems
3E3M

Hashmap Frequency / State Counting

Track counts or per-key state (character tallies, bijective mappings) in a single pass with a hashmap, then compare or query those counts.

9 problems
4E3M2H

Heap

3 patterns

Heap for Top-K / Kth Element

Maintain a fixed-size heap to track the k largest/smallest/most-frequent elements seen so far.

12 problems
2E7M3H

Quickselect

Use a partition step (like quicksort) to find the kth largest/smallest element in average O(n) without fully sorting.

1 problem
1M

Two Heaps (Median Maintenance)

Balance a max-heap of the lower half against a min-heap of the upper half to maintain a running median.

Intervals

1 pattern

Merge / Insert Intervals

Sort intervals by start time and merge or insert while adjacent intervals overlap.

6 problems
2E4M

Linked List

5 patterns

Fast/Slow Pointers (Cycle & Midpoint)

A tortoise-and-hare pair of pointers moving at different speeds to detect a cycle or find a midpoint/kth-from-end node.

7 problems
2E5M

Hashmap Node-to-Node Mapping

Use a hashmap as an old-object-to-new-object identity map to reconstruct a structure with internal cross-references (e.g. cloning a list with random pointers).

1 problem
1M

Linked List In-Place Reversal

Rewire next-pointers to reverse a linked list or a sublist in place without extra storage.

Math

4 patterns

Big-Number Arithmetic Simulation

Simulate elementary-school arithmetic (add/multiply) digit-by-digit with carries, because the operands exceed native integer range.

3 problems
1E2M

Digit Manipulation Simulation

Peel off and reconstruct a number digit-by-digit to reverse it, check a property, or apply an increment.

8 problems
7E1M

Game Parity Reasoning

Matrix

1 pattern

Matrix Traversal Simulation

Directly simulate a described traversal or transformation over a 2D matrix (spiral order, rotation, in-place zeroing).

5 problems
5M

Sliding Window

2 patterns

Sliding Window (Fixed Size)

Slide a window of constant size across the input, incrementally updating window state as it moves.

4 problems
1E1M2H

Sliding Window (Variable Size)

Expand and shrink a window's right/left edges based on a validity condition to find an optimal-length substring/subarray.

5 problems
1E3M1H

Stack

4 patterns

Monotonic Decreasing Stack

Maintain a stack that only ever decreases, popping elements when a larger one arrives to find next-greater relationships.

3 problems
2M1H

Monotonic Deque

Maintain a double-ended queue of candidate indices in monotonic order to answer sliding-window max/min in O(1) amortized.

2 problems
1M1H

Monotonic Increasing Stack

Maintain a stack that only ever increases, popping when a smaller element arrives to bound a region (e.g. largest rectangle).

Strings

2 patterns

Multi-Pass String Construction

Build an output string through several structured passes or an explicit layout algorithm, rather than one linear scan.

3 problems
2M1H

String Index Scanning

A single linear pass over string indices (with simple lookups/comparisons) to extract or convert a value.

5 problems
4E1M

Trees

12 patterns

BST Ordering Property

Exploit the left-less-than-node-less-than-right invariant of a BST to prune search space or produce sorted output.

6 problems
2E4M

Binary Indexed Tree (Fenwick Tree)

Use a BIT/Fenwick tree to answer prefix sum queries or range queries with point updates in O(log n) time, typically when the operation is associative and invertible.

3 problems
1M2H

Complete Tree Structural Binary Search

Tries

1 pattern

Trie / Prefix Tree

Build a tree of characters so prefix lookups, insertions, and searches share common paths.

4 problems
1E2M1H

Two Pointers

3 patterns

Sort Then Two Pointers

Sort the input first, then fix one element and use two pointers over the remainder to find combinations meeting a target.

1 problem
1M

Two Pointers (Opposite Ends)

Start pointers at both ends of a sorted or symmetric structure and move them toward each other based on a comparison.

5 problems
2E2M1H

Two Pointers (Same Direction)

GL
GrindLens

Precision pattern analytics and curated sheet tracking for algorithmic coding interview preparation.

Quick lookup:⌘Kor/

Platform

  • Patterns→
  • Sheets→
  • Pricing→

Community

  • Feedback
  • Report a bug
  • X
  • LinkedIn

© 2026 GrindLens. LeetCode is a trademark of LeetCode. GrindLens is an independent analytics platform and is not affiliated with or endorsed by LeetCode.

Terms of ServicePrivacy Policy
1 problem
1M

Backtracking - Permutations

Build all orderings of a set by swapping/marking used elements at each recursive level.

1 problem
1M

Backtracking - Subsets (Include/Exclude)

Build the recursion tree by deciding, for each element in turn, whether to include it in the current subset.

2 problems
2M

N-Queens Style Constraint Backtracking

Place items one row/column at a time, pruning branches immediately when a placement violates a global constraint set.

2 problems
2H

Binary search over the space of possible answer values, using a feasibility check to decide which half to keep.

4 problems
1E1M2H
2M

Grid / 2D Path DP

DP over a 2D grid where each cell's value depends on cells reachable by the allowed moves (down/right, etc.).

6 problems
5M1H

Interval DP

DP over subarray/substring ranges [i, j], combining results of smaller sub-ranges to solve larger ones.

1 problem
1H

Linear 1D DP

A DP recurrence over a single sequence where each state depends on a small fixed window of previous states.

8 problems
3E5M

Longest Increasing Subsequence DP

DP (optionally with binary search) tracking the best increasing subsequence length ending at each index.

1 problem
1M

Minimax Game State DP

DP where state represents game configuration (remaining piles, positions, turns) and we compute win/loss from each state assuming optimal play from both players.

12 problems
6M6H

State Machine DP

DP tracking which of several explicit states (e.g. holding/not-holding stock, in/out of cooldown) you're in at each step.

3 problems
1M2H

String Alignment / Subsequence DP

2D DP over two string indices to compare, align, or count subsequences/substrings between them.

7 problems
5M2H

Take/Skip Adjacent-Constraint DP

DP where taking an element forbids taking its immediate neighbor, tracking best-with/without-current at each step.

2 problems
2M

Unbounded Knapsack

DP where each item/coin can be reused an unlimited number of times while building toward a target.

3 problems
3M
1 problem
1M

Flood Fill

Recursively (or iteratively) spread a fill from a starting cell to all connected cells matching a condition.

3 problems
3M

Graph DFS Traversal

DFS across an explicit or implicit graph (adjacency list) to visit, clone, or reconstruct connected structure.

3 problems
2M1H

Grid DFS Traversal

DFS across grid cells following adjacency (usually 4-directional), typically to explore or measure a connected region.

5 problems
4M1H

Minimum Spanning Tree (Prim's/Kruskal's)

Build a minimum-weight tree connecting all nodes, either by growing from a frontier (Prim's) or sorting edges and using union-find (Kruskal's).

1 problem
1M

Multi-Source BFS

Seed the BFS queue with multiple starting nodes simultaneously so distances propagate from all sources in lockstep.

3 problems
3M

Topological Sort

Order nodes of a DAG so every directed edge points from earlier to later, via DFS post-order or Kahn's algorithm.

3 problems
2M1H

Union-Find / Disjoint Set

Maintain disjoint sets with union and find operations to detect connectivity or cycles as edges are processed.

4 problems
3M1H
2 problems
2M

Greedy Min/Max Range Tracking

Track a running [lower, upper] bound of possible values while scanning, collapsing or rejecting when the range becomes invalid.

1 problem
1M

Greedy Single-Pass Decision

Make a locally optimal choice while scanning once left to right, where the specific decision rule is simple enough not to warrant its own named pattern.

8 problems
7M1H

Greedy Two-Pass Comparison

Scan left-to-right then right-to-left (or vice versa), each pass enforcing a local ordering constraint against the neighbor.

1 problem
1H

Hashmap Grouping by Canonical Key

Bucket items together under a derived canonical key (e.g. sorted string) using a hashmap of lists.

1 problem
1M
1 problem
1H
4 problems
1E2M1H

Linked List Merge (K-Way)

Merge two or more already-sorted linked lists into one sorted list by repeatedly picking the smallest head.

2 problems
1E1H

Linked List Partition / Splice

Splice a linked list into separate chains by a pivot condition, then reconnect them in the required order.

1 problem
1M

Determine game outcome from simple parity, count-based, or mathematical invariants without full state DP (e.g., whether count is even/odd, modulo-based reasoning).

7 problems
3E4M

Number Theory

Apply a number-theoretic property (factor counting, GCD/slope reasoning) rather than a general-purpose algorithm.

7 problems
1E4M2H
1 problem
1H

Stack-Based Matching / Evaluation

Use a stack to match nested symbols or evaluate an expression by pushing/popping in the correct order.

5 problems
1E3M1H

Exploit a tree's complete (heap-shaped) structure to binary search for where the last level ends, unrelated to BST ordering.

1 problem
1E

Generic Recursive Tree DFS

Plain recursive depth-first traversal used to transform or visit every node, where no more specific tree pattern applies.

2 problems
1E1M

Lowest Common Ancestor

Find the deepest node that is an ancestor of two given nodes, via recursive search or BST-property comparison.

2 problems
2M

Segment Tree Range Queries

Build a segment tree to answer range queries (sum, min, max, etc.) or perform range updates in O(log n) time, often with lazy propagation.

3 problems
3H

Tree BFS / Level-Order Traversal

Process a tree level-by-level using a queue, tracking level boundaries as needed.

5 problems
1E4M

Tree Height / Balance Check

Compute subtree heights bottom-up during DFS to check depth or balance conditions, often with early termination.

2 problems
2E

Tree Path Value Accumulation

Carry a running value down (or aggregate a value up) a root-to-leaf or arbitrary path during DFS.

5 problems
2E2M1H

Tree Reconstruction from Traversals

Rebuild a binary tree from two given traversal orders by using one to locate roots and the other to size subtrees.

2 problems
2M

Tree Serialization / Deserialization

Encode a tree into a linear representation (e.g. preorder with null markers) and decode it back into the same structure.

1 problem
1H

Tree Structural Comparison

Recursively compare two trees (or a tree against a mirrored version of itself) node-by-node for structural/value equality.

3 problems
3E

A read/write or slow/fast pair of pointers moving the same direction through a sequence, compacting or scanning in place.

6 problems
3E3M