Learning pathsPricingChecking sign-in…

CODE & DSA · PATTERN LIBRARY

DSA patterns and problem roadmap

This library consolidates the two supplied lists. The guide view preserves its “when to use” and recognition-clue framing; the roadmap view preserves its ordered problem groups. The same LeetCode question may appear in more than one pattern because patterns overlap.

25guide patterns
24roadmap groups
263unique questions
136 / 127in DSA bank / external

“In DSA bank” opens an AceYourInterviews problem with its local editor and learning material. “LeetCode” opens an external problem because it is not yet authored in the in-site DSA bank; it is not counted as a completed local lesson.

25 matching groups · 263 distinct questions across both lists

HashMap / HashSet9 questions

You need fast lookup, frequency counting, duplicate detection, or complement matching.

Recognition clues: “frequency,” “duplicates,” “pair sums to target,” “longest consecutive,” “number of subarrays.”

Two Pointers8 questions

You can move two indices to reduce the search space, especially on sorted arrays or strings.

Recognition clues: Sorted input, pair/triplet search, in-place array changes, left/right boundaries.

Sliding Window8 questions

You need to examine contiguous ranges and can maintain a window as it expands or shrinks.

Prefix Sum7 questions

You need cumulative sums, range-sum calculations, or to count subarrays with a particular sum.

Recognition clues: “subarray sum equals K,” “sum between indices,” “divisible by K,” “number of ranges.”

Kadane's Algorithm2 questions

Finding the maximum sum of a contiguous subarray.

Binary Search9 questions

Data is sorted, or the answer can be searched through a monotonic condition.

Recognition clues: Sorted data, first/last occurrence, minimum feasible capacity, minimum speed, maximize/minimize an answer under constraints.

Sorting and Intervals7 questions

Ranges overlap, need merging, or ordering simplifies the problem.

Recognition clues: Start/end times, overlapping ranges, meeting schedules, minimum rooms or removals.

Sweep Line / Event Sorting4 questions

You need to process start/end events in chronological order, often to find the maximum number of simultaneous events.

Stack / Monotonic Stack8 questions

Matching nested structures, processing elements in reverse order, or finding next greater/smaller elements.

Recognition clues: Brackets, nested expressions, next greater element, nearest smaller element, histogram.

Queue / Monotonic Queue4 questions

You need FIFO processing or the maximum/minimum in a moving window.

Linked Lists9 questions

Manipulating nodes, reversing pointers, detecting cycles, or finding middle nodes.

Recognition clues: Fast/slow pointers, dummy node, reverse links, merge sorted lists, operations near the tail.

Binary Trees / DFS10 questions

Calculating height, checking tree properties, finding paths, or exploring ancestors.

Binary Search Trees (BST)6 questions

The tree's ordering property can eliminate unnecessary searches.

BFS / DFS on Grids8 questions

A matrix represents connected cells, regions, or movement between locations.

Recognition clues: Islands, regions, grid movement, shortest path by number of steps, multi-source BFS.

Graph DFS / BFS6 questions

Nodes are connected by edges and you need reachability, connected components, or shortest paths in unweighted graphs.

Topological Sort4 questions

Tasks have dependencies and you need a valid ordering or need to detect a dependency cycle.

Union-Find (Disjoint Set Union)5 questions

You need to connect groups, determine whether two nodes belong to the same component, or detect redundant edges.

Shortest Paths and Minimum Spanning Trees5 questions

Edges have weights or you need the cheapest way to connect a graph.

Heap / Priority Queue7 questions

You repeatedly need the smallest/largest item, top K results, or the next task by priority.

Backtracking8 questions

You must explore multiple choices, build candidates, and undo a choice before trying another.

Trie / Prefix Tree4 questions

Searching words by prefix, implementing a dictionary, or sharing common prefixes efficiently.

1D Dynamic Programming8 questions

The answer for a larger problem depends on solutions to smaller prefixes or states.

2D Dynamic Programming7 questions

The state depends on two dimensions, such as two strings, two indices, or grid coordinates.

Knapsack / Subset DP5 questions

You select items or numbers subject to a capacity, target, or constraint.

Greedy7 questions

A locally optimal choice can be shown to lead to a globally optimal solution.

← Back to the complete in-site DSA problem bank