7/8/26, 2:19 PM Leetcode Patterns
⭐ 13.3k Sign in with GitHub
by Sean Prashad · Est. 2019
A collection of 179 questions grouped by pattern to
help you prepare for coding interviews.
All Questions Beginner Roadmap Experienced Roadmap
Beginner Roadmap
A structured path for those new to coding interviews.
Sean's Guidance:
1. Choose a programming language that you feel most comfortable with - for me that is Java. If you're new
to programming, I would recommend Python.
2. Spend no more than 30 minutes trying to think of any solution, even if it's brute force. You want to try
applying what you know, and if stuck, then expand your skillset by studying the solution until you're able
to fully explain it to another individual.
3. Expect to struggle at first (for my first time, it took at least a month to begin improving).
4. Do not memorize solutions - this does not work in interviews when asked follow-up questions (I speak
from experience).
5. Don't be afraid to ask an AI agent to explain the solution to you - it's a great alternative to watching a
video solution.
6. Reference the Helpful Tips tab for which tools to consider pulling out of your toolkit when solving a
problem - don't use a screwdriver when you need a hammer!
0/68 completed (0%)
Easy 0/31 completed (0%)
Build your foundation with these introductory problems
Phase 1: Arrays & Hash Tables 0/5
1 Learn the two most fundamental data structures. Arrays teach you iteration and indexing; hash tables give
you O(1) lookups.
Contains Duplicate Array Hash Table Sorting
💡 Show hint
Two Sum Array Hash Table
[Link] 1/11
7/8/26, 2:19 PM Leetcode Patterns
💡 Show hint
Find All Numbers Disappeared in an Array Array Hash Table
💡 Show hint
Missing Number
Array Hash Table Math Binary Search Bit Manipulation Sorting
💡 Show hint
Majority Element Array Hash Table Divide and Conquer Sorting Counting
💡 Show hint
Phase 2: Two Pointers 0/3
2
Two pointers let you solve problems in O(n) by scanning from both ends or using a slow/fast pointer.
Move Zeroes Array Two Pointers
💡 Show hint
Squares of a Sorted Array Array Two Pointers Sorting
💡 Show hint
Backspace String Compare Two Pointers String Stack Simulation
💡 Show hint
Phase 3: Sliding Window 0/2
3 Sliding window optimizes brute-force subarray/substring problems from O(n²) to O(n) by maintaining a
moving window.
Maximum Average Subarray I Array Sliding Window
💡 Show hint
Is Subsequence Two Pointers String Dynamic Programming
[Link] 2/11
7/8/26, 2:19 PM Leetcode Patterns
💡 Show hint
Phase 4: Linked Lists 0/7
4 Master pointer manipulation with linked lists. These problems build intuition for in-place data structure
operations.
Reverse Linked List Linked List Recursion
💡 Show hint
Middle of the Linked List Linked List Two Pointers
💡 Show hint
Linked List Cycle Hash Table Linked List Two Pointers
💡 Show hint
Merge Two Sorted Lists Linked List Recursion
💡 Show hint
Remove Linked List Elements Linked List Recursion
💡 Show hint
Remove Duplicates from Sorted List Linked List
💡 Show hint
Palindrome Linked List Linked List Two Pointers Stack Recursion
💡 Show hint
Phase 5: Binary Search 0/2
5 Binary search halves the search space each iteration for O(log n) time. Master the template: left, right, mid
boundaries.
Binary Search Array Binary Search
💡 Show hint
[Link] 3/11
7/8/26, 2:19 PM Leetcode Patterns
Find Smallest Letter Greater Than Target Array Binary Search
💡 Show hint
Phase 6: Trees - DFS & BFS 0/9
6 Trees combine recursion with data structures. DFS (preorder, inorder, postorder) and BFS (level-order) are
the core traversals.
Maximum Depth of Binary Tree
Tree Depth-First Search Breadth-First Search Binary Tree
💡 Show hint
Minimum Depth of Binary Tree
Tree Depth-First Search Breadth-First Search Binary Tree
💡 Show hint
Same Tree Tree Depth-First Search Breadth-First Search Binary Tree
💡 Show hint
Invert Binary Tree Tree Depth-First Search Breadth-First Search Binary Tree
💡 Show hint
Path Sum Tree Depth-First Search Breadth-First Search Binary Tree
💡 Show hint
Subtree of Another Tree
Tree Depth-First Search String Matching Binary Tree Hash Function
💡 Show hint
[Link] 4/11
7/8/26, 2:19 PM Leetcode Patterns
Binary Tree Paths String Backtracking Tree Depth-First Search Binary Tree
💡 Show hint
Merge Two Binary Trees
Tree Depth-First Search Breadth-First Search Binary Tree
💡 Show hint
Average of Levels in Binary Tree
Tree Depth-First Search Breadth-First Search Binary Tree
💡 Show hint
Phase 7: Sorting & Intervals 0/1
7
Sorting unlocks many techniques. Interval problems almost always start with sorting by start time.
Meeting Rooms Array Sorting
💡 Show hint
Phase 10: Matrix Traversal 0/1
10
Apply array and graph techniques to 2D grids. Row/column math and directional traversal are key skills.
Convert 1D Array Into 2D Array Array Matrix Simulation
💡 Show hint
Phase 11: Prefix Sums 0/1
11 Prefix sums let you compute range sums in O(1) after O(n) preprocessing. A powerful technique for
subarray problems.
Range Sum Query - Immutable Array Design Prefix Sum
💡 Show hint
[Link] 5/11
7/8/26, 2:19 PM Leetcode Patterns
Medium 0/37 completed (0%)
Medium difficulty problems begin introducing new techniques and algorithms - most of the time you will need
to study the optimal solution
Phase 1: Arrays & Hash Tables 0/2
1 Apply array and hash table skills to trickier problems that require multi-pass strategies or in-place
techniques.
Product of Array Except Self Array Prefix Sum
💡 Show hint
Find All Duplicates in an Array Array Hash Table Sorting
💡 Show hint
Phase 2: Two Pointers 0/4
2 Combine sorting with two-pointer scans to handle duplicates, multi-element sums, and greedy boundary
decisions.
3Sum Array Two Pointers Sorting
💡 Show hint
3Sum Closest Array Two Pointers Sorting
💡 Show hint
Container With Most Water Array Two Pointers Greedy
💡 Show hint
Sort Colors Array Two Pointers Sorting
💡 Show hint
Phase 3: Sliding Window 0/6
3 Handle variable-width windows with shrink conditions, frequency maps, and constraints like "at most k"
distinct elements.
[Link] 6/11
7/8/26, 2:19 PM Leetcode Patterns
Longest Substring Without Repeating Characters
Hash Table String Sliding Window
💡 Show hint
Minimum Size Subarray Sum
Array Binary Search Sliding Window Prefix Sum
💡 Show hint
Longest Repeating Character Replacement
Hash Table String Sliding Window
💡 Show hint
Permutation in String Hash Table Two Pointers String Sliding Window
💡 Show hint
Fruit Into Baskets Array Hash Table Sliding Window
💡 Show hint
Subarray Product Less Than K
Array Binary Search Sliding Window Prefix Sum
💡 Show hint
Phase 4: Linked Lists 0/1
4
Chain together multiple linked list techniques (find middle, reverse, merge) within a single problem.
Remove Nth Node From End of List Linked List Two Pointers
💡 Show hint
Phase 5: Binary Search 0/5
5 Apply binary search to modified arrays - rotated, 2D, or peak-finding - where you must decide which half to
discard.
[Link] 7/11
7/8/26, 2:19 PM Leetcode Patterns
Peak Index in a Mountain Array Array Binary Search
💡 Show hint
Search in Rotated Sorted Array Array Binary Search
💡 Show hint
Find Minimum in Rotated Sorted Array Array Binary Search
💡 Show hint
Search a 2D Matrix Array Binary Search Matrix
💡 Show hint
Find Peak Element Array Binary Search
💡 Show hint
Phase 6: Trees - DFS & BFS 0/2
6 Tackle tree problems that require maintaining global state, enforcing BST constraints, or processing nodes
level by level.
Binary Tree Level Order Traversal Tree Breadth-First Search Binary Tree
💡 Show hint
Validate Binary Search Tree
Tree Depth-First Search Binary Search Tree Binary Tree
💡 Show hint
Phase 7: Sorting & Intervals 0/4
7 Merge, insert, and remove overlapping intervals. These problems layer greedy decisions on top of sorted
input.
Merge Intervals Array Sorting
[Link] 8/11
7/8/26, 2:19 PM Leetcode Patterns
💡 Show hint
Insert Interval Array
💡 Show hint
Non-overlapping Intervals Array Dynamic Programming Greedy Sorting
💡 Show hint
Interval List Intersections Array Two Pointers Sweep Line
💡 Show hint
Phase 9: Graphs - BFS & DFS 0/5
8
Build on tree traversals. Graphs add cycles and multiple paths, requiring visited tracking.
Number of Islands
Array Depth-First Search Breadth-First Search Union-Find Matrix
💡 Show hint
Pacific Atlantic Water Flow
Array Depth-First Search Breadth-First Search Matrix
💡 Show hint
Graph Valid Tree
Depth-First Search Breadth-First Search Union-Find Graph Theory
💡 Show hint
Number of Connected Components in an Undirected Graph
Depth-First Search Breadth-First Search Union-Find Graph Theory
💡 Show hint
Course Schedule
Depth-First Search Breadth-First Search Graph Theory Topological Sort
[Link] 9/11
7/8/26, 2:19 PM Leetcode Patterns
💡 Show hint
Phase 10: Heaps & Priority Queues 0/5
9
Heaps efficiently maintain the min or max element. Essential for 'top K' and streaming problems.
Kth Largest Element in an Array
Array Divide and Conquer Sorting Heap (Priority Queue) Quickselect
💡 Show hint
Top K Frequent Elements
Array Hash Table Divide and Conquer Sorting Heap (Priority Queue)
Bucket Sort Counting Quickselect
💡 Show hint
K Closest Points to Origin
Array Math Divide and Conquer Geometry Sorting Heap (Priority Queue)
Quickselect
💡 Show hint
Meeting Rooms II
Array Two Pointers Greedy Sorting Heap (Priority Queue) Prefix Sum
💡 Show hint
Kth Smallest Element in a Sorted Matrix
Array Binary Search Sorting Heap (Priority Queue) Matrix
💡 Show hint
Phase 10: Matrix Traversal 0/3
10 Navigate matrices with boundary tracking, in-place marking, and coordinate transformations like transpose
and spiral order.
[Link] 10/11
7/8/26, 2:19 PM Leetcode Patterns
Set Matrix Zeroes Array Hash Table Matrix
💡 Show hint
Spiral Matrix Array Matrix Simulation
💡 Show hint
Rotate Image Array Math Matrix
💡 Show hint
Next Steps
What to do after completing this roadmap
1 Re-solve problems that gave you trouble - if a question stumped you, redo it until the approach
clicks. Repetition is how patterns become second nature.
2 Remember to study solutions using an AI agent/YouTube video if you get stuck - I still have to do
this occassionally for some questions!
3 Move onto the Experienced Roadmap to solidify your understanding of each pattern across all
difficulty levels.
4 Complete additional questions from the All Questions tab - filter by pattern or difficulty to target your
weak areas.
[Link] 11/11