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.
“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.”
- #1 Two SumIn DSA bankEasy
- #217 Contains DuplicateIn DSA bankFoundation
- #242 Valid AnagramIn DSA bankFoundation
- #49 Group AnagramsIn DSA bankIntermediate
- #347 Top K Frequent ElementsIn DSA bankCore
- #128 Longest Consecutive SequenceIn DSA bankIntermediate
- #380 Insert Delete GetRandom O(1)LeetCodeMedium
- #560 Subarray Sum Equals KIn DSA bankIntermediate
- #525 Contiguous Array — Equal Zeroes and OnesIn DSA bankIntermediate
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.
- #125 Valid PalindromeIn DSA bankEasy
- #167 Two Sum in a Sorted ArrayIn DSA bankIntermediate
- #283 Move ZeroesIn DSA bankEasy
- #11 Container With Most WaterIn DSA bankIntermediate
- #15 3SumIn DSA bankAdvanced
- #26 Remove Duplicates from Sorted ArrayIn DSA bankIntermediate
- #42 Trapping Rain WaterIn DSA bankHard
- #75 Sort ColorsIn DSA bankIntermediate
Sliding Window8 questions
You need to examine contiguous ranges and can maintain a window as it expands or shrinks.
- #121 Best Time to Buy and Sell Stock — One TransactionIn DSA bankStarter
- #3 Longest Substring Without Repeating CharactersIn DSA bankIntermediate
- #209 Minimum Size Subarray Sum — Positive InputsIn DSA bankIntermediate
- #424 Longest Repeating Character ReplacementIn DSA bankIntermediate
- #567 Permutation in StringIn DSA bankIntermediate
- #438 Find All Anagrams in a StringIn DSA bankIntermediate
- #76 Minimum Window SubstringIn DSA bankAdvanced
- #239 Sliding Window MaximumIn DSA bankAdvanced
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.”
- #303 Range Sum Query — ImmutableIn DSA bankIntermediate
- #560 Subarray Sum Equals KIn DSA bankIntermediate
- #523 Continuous Subarray SumLeetCodeMedium
- #525 Contiguous Array — Equal Zeroes and OnesIn DSA bankIntermediate
- #974 Count Subarrays Divisible by KIn DSA bankIntermediate
- #238 Product of Array Except SelfIn DSA bankIntermediate
- #304 Range Sum Query 2D — ImmutableIn DSA bankIntermediate
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.
- #704 Binary Search — Exact LookupIn DSA bankCore
- #35 Search Insert Position — Lower BoundIn DSA bankCore
- #74 Search a Row-major Sorted MatrixIn DSA bankCore
- #33 Search in Rotated Sorted ArrayIn DSA bankCore
- #153 Minimum in Rotated Sorted ArrayIn DSA bankCore
- #34 First and Last Position of a TargetIn DSA bankCore
- #875 Koko Eating Bananas — Minimum Feasible RateIn DSA bankCore
- #1011 Capacity to Ship Packages Within D DaysIn DSA bankIntermediate
- #4 Median of Two Sorted ArraysIn DSA bankAdvanced
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.
- #56 Merge IntervalsIn DSA bankIntermediate
- #57 Insert IntervalIn DSA bankIntermediate
- #435 Non-overlapping IntervalsIn DSA bankIntermediate
- #452 Minimum Arrows to Burst BalloonsIn DSA bankIntermediate
- #986 Interval List IntersectionsLeetCodeMedium
- #252 Meeting Rooms — Conflict DetectionIn DSA bankIntermediate
- #253 Meeting Rooms II — Resource CountIn DSA bankIntermediate
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.
- #20 Valid ParenthesesIn DSA bankIntermediate
- #155 Min StackIn DSA bankIntermediate
- #150 Evaluate Reverse Polish NotationIn DSA bankIntermediate
- #739 Daily TemperaturesIn DSA bankIntermediate
- #496 Next Greater Element ILeetCodeEasy
- #503 Next Greater Element — Circular ArrayIn DSA bankIntermediate
- #84 Largest Rectangle in HistogramIn DSA bankAdvanced
- #394 Decode StringLeetCodeMedium
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.
- #206 Reverse Linked ListIn DSA bankFoundation
- #21 Merge Two Sorted ListsIn DSA bankCore
- #141 Linked List Cycle DetectionIn DSA bankCore
- #142 Find Linked List Cycle EntryIn DSA bankCore
- #19 Remove Nth Node from EndIn DSA bankCore
- #876 Middle of the Linked ListLeetCodeEasy
- #2 Add Two Numbers — Reversed DigitsIn DSA bankCore
- #143 Reorder ListIn DSA bankCore
- #146 LRU CacheIn DSA bankAdvanced
Binary Trees / DFS10 questions
Calculating height, checking tree properties, finding paths, or exploring ancestors.
- #104 Maximum Depth of Binary TreeIn DSA bankFoundation
- #100 Same TreeIn DSA bankCore
- #226 Invert Binary TreeIn DSA bankCore
- #543 Diameter of Binary TreeIn DSA bankCore
- #110 Balanced Binary TreeIn DSA bankCore
- #112 Path SumLeetCodeEasy
- #102 Binary Tree Level Order TraversalIn DSA bankCore
- #236 Lowest Common Ancestor of a Binary TreeIn DSA bankAdvanced
- #199 Binary Tree Right Side ViewLeetCodeMedium
- #124 Binary Tree Maximum Path SumIn DSA bankAdvanced
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.
- #733 Flood FillIn DSA bankCore
- #200 Number of IslandsIn DSA bankIntermediate
- #695 Maximum Area of IslandIn DSA bankCore
- #994 Rotting OrangesIn DSA bankIntermediate
- #130 Surrounded RegionsIn DSA bankCore
- #542 01 MatrixLeetCodeMedium
- #1091 Shortest Path in a Binary MatrixIn DSA bankCore
- #417 Pacific Atlantic Water FlowIn DSA bankAdvanced
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.
- #215 Kth Largest Element in an ArrayIn DSA bankIntermediate
- #347 Top K Frequent ElementsIn DSA bankCore
- #973 K Closest Points to OriginIn DSA bankCore
- #703 Kth Largest Element in a StreamIn DSA bankCore
- #621 Task Scheduler with CooldownIn DSA bankCore
- #295 Find Median from Data StreamIn DSA bankAdvanced
- #23 Merge K Sorted ListsIn DSA bankCore
Backtracking8 questions
You must explore multiple choices, build candidates, and undo a choice before trying another.
- #78 SubsetsIn DSA bankIntermediate
- #46 PermutationsIn DSA bankIntermediate
- #39 Combination Sum — Reusable CandidatesIn DSA bankIntermediate
- #40 Combination Sum II — Each Candidate OnceIn DSA bankIntermediate
- #17 Letter Combinations of a Phone NumberLeetCodeMedium
- #79 Word Search — Single WordIn DSA bankAdvanced
- #22 Generate ParenthesesLeetCodeMedium
- #51 N-QueensIn DSA bankAdvanced
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.
- #70 Climbing StairsIn DSA bankFoundational
- #198 House RobberIn DSA bankIntermediate
- #213 House Robber IIIn DSA bankIntermediate
- #746 Min Cost Climbing StairsIn DSA bankIntermediate
- #53 Maximum SubarrayLeetCodeKadane's algorithm
- #322 Coin Change — Minimum CoinsIn DSA bankIntermediate
- #300 Longest Increasing SubsequenceIn DSA bankAdvanced
- #139 Word BreakIn DSA bankIntermediate
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.
- #55 Jump Game — ReachabilityIn DSA bankIntermediate
- #45 Jump Game II — Minimum JumpsIn DSA bankIntermediate
- #122 Best Time to Buy and Sell Stock IILeetCodeMedium
- #134 Gas StationIn DSA bankIntermediate
- #763 Partition LabelsIn DSA bankIntermediate
- #846 Hand of StraightsLeetCodeMedium
- #406 Queue Reconstruction by HeightIn DSA bankAdvanced