Skip to content
DSA Patterns
Menu
Language

Pattern catalog

Each card is a technique: cues, template, and a problem path. Status chip top-right; path inventory under the title (for example “6 guides and a template”); your completion counts sit on the right once you start.

Showing 1 to 37 of 37

#01Essential
Not started

Sliding Window

Longest, shortest, or valid contiguous ranges over arrays and strings.

6 guides and a template

#02Essential
Not started

Two Pointers

Sorted arrays, pair conditions, or coordinated movement from both ends.

6 guides and a template

#03Essential
Not started

Fast & Slow Pointers

Linked-list cycles, middle nodes, and fixed pointer gaps.

6 guides and a template

#04Essential
Not started

Binary Search

Halve a sorted or monotonic search space until you pin the answer.

6 guides and a template

#05Essential
Not started

Binary Search on Answer

Binary search the answer value itself; check if a candidate is feasible in linear time.

6 guides and a template

#06Essential
Not started

Hashing

O(1) average lookup, frequency counting, grouping, and complement checks.

6 guides and a template

#07Essential
Not started

Prefix Sum

Precompute running sums so any range sum is O(1); pair with maps for subarray sum counts.

6 guides and a template

#08Recommended
Not started

Difference Array

Range updates in O(1); rebuild the array with a prefix pass.

6 guides and a template

#09Recommended
Not started

Monotonic Stack

Next greater/smaller, histogram rectangles, and temperature waits.

6 guides and a template

#10Recommended
Not started

Stack Parsing

Nested structures, expressions, paths, and collision simulation.

6 guides and a template

#11Recommended
Not started

Queue & Deque

FIFO processing, sliding-window extrema, and recent-event tracking.

6 guides and a template

#12Essential
Not started

Intervals

Sort by start or end, then merge, insert, or remove overlaps.

6 guides and a template

#13Essential
Not started

Heap & Top K

Repeated extract-min/max or maintain the K best under a stream.

6 guides and a template

#14Essential
Not started

Grid & Graph BFS

Shortest paths in unweighted graphs and multi-source floods on grids.

6 guides and a template

#15Essential
Not started

Backtracking

Choose, explore, undo. Build all valid combinations or search with pruning.

6 guides and a template

#16Essential
Not started

Tree DFS

Define what each subtree returns to its parent.

6 guides and a template

#17Recommended
Not started

Tree BFS

Level-order processing for width, views, and per-level aggregates.

6 guides and a template

#18Recommended
Not started

Trie

Prefix trees for dictionaries, word search, and shared prefixes.

6 guides and a template

#19Advanced
Not started

Union Find

Dynamic connectivity: merge components and query same-set fast.

6 guides and a template

#20Advanced
Not started

Topological Sort

Order nodes so every directed edge goes from earlier to later.

6 guides and a template

#21Recommended
Not started

Greedy

Make the best local choice when you can prove it never ruins the global optimum.

6 guides and a template

#22Essential
Not started

One-Dimensional DP

Define dp[i] clearly, then relate it to smaller indices.

6 guides and a template

#23Essential
Not started

Two-Dimensional DP

State depends on two changing indices (grid, two strings, two pointers in DP).

6 guides and a template

#24Advanced
Not started

Knapsack & Subset DP

Choose items under a capacity or hit an exact sum/target.

6 guides and a template

#25Recommended
Not started

Bit Manipulation

XOR, masks, shifts, and set-bit tricks for O(1) state.

6 guides and a template

#26Essential
Not started

Graph DFS

Connected components, flood fill, cycle detection, paths.

6 guides and a template

#27Recommended
Not started

Shortest Path (Weighted)

Dijkstra, Bellman-Ford: minimum cost in a weighted graph.

6 guides and a template

#28Recommended
Not started

Sweep Line

Process events sorted by coordinate; detect overlaps/skyline.

6 guides and a template

#29Advanced
Not started

Segment Tree / BIT

Point update, range query in O(log n); prefix sums with mutation.

6 guides and a template

#30Recommended
Not started

Quick Select

Partition-based selection: kth smallest, top K in O(n) average.

6 guides and a template

#31Essential
Not started

Linked List Manipulation

Reversal, in-place merge, dummy head, splice, and partition.

6 guides and a template

#32Recommended
Not started

Math & Number Theory

Modular arithmetic, primes, GCD/LCM, combinatorics, sieve.

6 guides and a template

#33Expert
Not started

Meet in the Middle

Split input in half, enumerate each, merge results. For n ~ 40.

6 guides and a template

#34Expert
Not started

Bitmask DP

DP with bitmask state: TSP-style, assignment, subset transitions.

6 guides and a template

#35Advanced
Not started

KMP / String Matching

Linear-time pattern matching via failure function; rolling hash.

6 guides and a template

#36Advanced
Not started

Minimum Spanning Tree

Kruskal / Prim: connect all nodes at minimum total edge cost.

6 guides and a template

#37Expert
Not started

Reservoir Sampling

Uniform sampling from a stream of unknown length. R-eviction.

6 guides and a template