Extended Problem List — Pattern Classification
Goal: Organize a large problem set by pattern, so you study by approach rather than by problem name. How to use: identify the pattern first, then work through problems in that group in order.
Pattern Summary
This document groups a larger interview problem set by approach instead of by title. The main learning goal is to notice pattern signals early, then choose a matching template: hash map, two pointers, sliding window, binary search, recursion, graph traversal, heap, or dynamic programming.
Problem Meaning
This page is a pattern index, not one standalone LeetCode prompt. To make the classification idea concrete, the representative example below uses Longest Substring Without Repeating Characters, because it is one of the cleanest sliding-window patterns in the larger practice set.
Python Code
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
left = 0
seen: dict[str, int] = {}
best = 0
for right, ch in enumerate(s):
if ch in seen and seen[ch] >= left:
left = seen[ch] + 1
seen[ch] = right
best = max(best, right - left + 1)
return best
print(Solution().lengthOfLongestSubstring('abcabcbb'))
Time Complexity
Each character is processed at most a constant number of times, so the time complexity is O(n).
Space Complexity
The hash map stores the latest index of characters in the current history, so the extra space complexity is O(min(n, charset)).
How To Think About It
The wording “longest substring without repeating characters” should trigger a sliding-window signal: a continuous range with a validity rule. Once you recognize that, the question becomes “expand the window, and when it becomes invalid, move the left boundary until it is valid again.” This is the exact recognition habit the whole extended pattern list is trying to build.
Example Case
Input: s = "abcabcbb"
Output: 3
Explanation: the longest valid substrings are "abc", "bca", and "cab", all of length 3.
Edge case: for s = "bbbbb", the answer is 1 because every valid window can contain only one b.
Common Follow-up Questions
- If the validity rule changes from “no repeated characters” to “at most k distinct characters,” what changes in the window state?
- When should a substring problem use sliding window, and when should it use dynamic programming instead?
- If the input is not continuous-subarray based, what signal tells you to leave the sliding-window pattern?
Overall Learning Sequence
Work through topics in this order:
- Arrays, Two Pointers, Sliding Window
- Binary Search
- Linked List
- Trees and Recursion
- DFS / Backtracking
- BFS / Graph
- Stack and Queue
- Dynamic Programming
- Heap / Top K
- Design
- Intervals, Math, and Miscellaneous
Reasoning: build foundational operations and pattern recognition first, then move to trees/graphs/backtracking templates, and finish with DP, design, and mixed problems.
Section 1: Arrays, Two Pointers, Sliding Window
Recognition Signals
complement / frequency / dedup → hash map
left-right squeeze, sorted, triplets → two pointers
consecutive subarray / substring, min/max span → sliding window
in-place modification, preserve order → slow/fast pointer
Sub-categories
1. Hash / Basic Array
- Two Sum
- Group Anagrams
- Intersection of Two Arrays
- Intersection of Two Arrays II
- Single Number
- Find All Duplicates in an Array
- Find the Duplicate Number
Key:
use dict/set to trade space for time
check before you store
2. In-Place Array Operations
- Move Zeroes
- Sort Colors
- Merge Sorted Array
- String Compression
- Next Permutation
Key:
be very clear about what each pointer boundary means
the invariant: what has already been processed
3. Two Pointers
- 3Sum
- 3Sum Closest
- Container With Most Water
- Squares of a Sorted Array
- Reverse String
- Valid Anagram
Key:
sort first, fix one element, then squeeze from both ends
or left-right squeeze directly
4. Sliding Window
- Longest Substring Without Repeating Characters
- Minimum Window Substring
- Longest Substring with At Most K Distinct Characters
- Max Consecutive Ones III
- Permutation in String
- Sliding Window Maximum
Key:
expand the window
when it becomes invalid, shrink from the left
update the answer after each valid window
Recommended Order
- Two Sum
- Move Zeroes
- Valid Anagram
- Reverse String
- Group Anagrams
- Intersection of Two Arrays
- Product of Array Except Self
- Sort Colors
- Merge Sorted Array
- Container With Most Water
- 3Sum
- Longest Substring Without Repeating Characters
- Permutation in String
- Minimum Window Substring
- Sliding Window Maximum
- Next Permutation
- Find the Duplicate Number
Section 2: Binary Search
Recognition Signals
sorted array
rotated sorted array
first / last occurrence
monotone condition
find minimum value satisfying a condition
Basic Binary Search
- Search in Rotated Sorted Array
- Find First and Last Position of Element in Sorted Array
- Find Peak Element
- Single Element in a Sorted Array
- Search a 2D Matrix
- Find Minimum in Rotated Sorted Array
- Search in Rotated Sorted Array II
- Search a 2D Matrix II
Advanced Binary Search / Binary Search on Answer
- Random Pick with Weight
- Kth Smallest Element in a Sorted Matrix
- Median of Two Sorted Arrays
- Closest Binary Search Tree Value
- Find the Celebrity
Recommended Order
- Search a 2D Matrix
- Find First and Last Position of Element in Sorted Array
- Search in Rotated Sorted Array
- Find Minimum in Rotated Sorted Array
- Find Peak Element
- Single Element in a Sorted Array
- Search a 2D Matrix II
- Search in Rotated Sorted Array II
- Kth Smallest Element in a Sorted Matrix
- Random Pick with Weight
- Median of Two Sorted Arrays
Key Insight
Binary search is not just "halving a sorted array"
Its essence is exploiting monotonicity:
if a condition is true for X, it's true for all values above/below X
Section 3: Linked List
Recognition Signals
reverse
remove nth from end
merge sorted lists
random pointer
reorder / partial reversal
Sub-categories
1. Reversal and Basic Operations
- Reverse Linked List
- Reverse Linked List II
- Reorder List
- Remove Nth Node From End of List
2. Merging and Arithmetic
- Add Two Numbers
- Add Two Numbers II
- Merge Two Sorted Lists
- Merge k Sorted Lists
- Sort List
3. Special Structures
- Intersection of Two Linked Lists
- Copy List with Random Pointer
Recommended Order
- Reverse Linked List
- Merge Two Sorted Lists
- Remove Nth Node From End of List
- Add Two Numbers
- Intersection of Two Linked Lists
- Reorder List
- Reverse Linked List II
- Copy List with Random Pointer
- Sort List
- Merge k Sorted Lists
- Add Two Numbers II
Key Patterns
dummy node
fast/slow pointers
reversal
merge
cut and reattach
Section 4: Trees and Recursion
Recognition Signals
depth, height, path, ancestor, construction, serialization
BST ordering properties
per-level information
Sub-categories
1. Traversal / Views
- Binary Tree Level Order Traversal
- Binary Tree Right Side View
- Binary Tree Vertical Order Traversal
- Vertical Order Traversal of a Binary Tree
- Find Largest Value in Each Tree Row
- Maximum Width of Binary Tree
- Populating Next Right Pointers in Each Node
- Populating Next Right Pointers in Each Node II
2. Paths and Sums
- Binary Tree Maximum Path Sum
- Path Sum
- Path Sum II
- Path Sum III
- Sum Root to Leaf Numbers
3. Properties and Transformations
- Symmetric Tree
- Diameter of Binary Tree
- Flatten Binary Tree to Linked List
- Construct Binary Tree from Preorder and Inorder Traversal
- Lowest Common Ancestor of a Binary Tree
4. BST and Serialization
- Validate Binary Search Tree
- Lowest Common Ancestor of a Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Convert Binary Search Tree to Sorted Doubly Linked List
- Kth Smallest Element in a BST
- Range Sum of BST
- Serialize and Deserialize Binary Tree
- Serialize and Deserialize BST
Recommended Order
- Symmetric Tree
- Binary Tree Level Order Traversal
- Binary Tree Right Side View
- Diameter of Binary Tree
- Path Sum
- Path Sum II
- Sum Root to Leaf Numbers
- Lowest Common Ancestor of a Binary Tree
- Flatten Binary Tree to Linked List
- Construct Binary Tree from Preorder and Inorder Traversal
- Validate Binary Search Tree
- Kth Smallest Element in a BST
- Lowest Common Ancestor of a Binary Search Tree
- Convert Sorted Array to Binary Search Tree
- Path Sum III
- Binary Tree Maximum Path Sum
- Serialize and Deserialize Binary Tree
- Serialize and Deserialize BST
Key Patterns
choose traversal first:
preorder → construction
inorder → BST
postorder → aggregate subtree info
level-order → per-level views
Section 5: DFS / Backtracking
Recognition Signals
all combinations
all permutations
all valid arrangements
try a choice, undo if it doesn't work
Problems
- Subsets
- Permutations
- Combination Sum
- Generate Parentheses
- Letter Combinations of a Phone Number
- Restore IP Addresses
- Binary Tree Paths
- Word Break II
- Partition to K Equal Sum Subsets
Recommended Order
- Letter Combinations of a Phone Number
- Subsets
- Permutations
- Combination Sum
- Generate Parentheses
- Restore IP Addresses
- Binary Tree Paths
- Word Break II
- Partition to K Equal Sum Subsets
Key Questions
what goes in the path?
where does start begin?
do I need a used[] array?
when do I prune?
Section 6: BFS / Graph
Recognition Signals
shortest path
layer-by-layer spreading
islands / connected components
dependency relationships / topological sort
Sub-categories
1. BFS / Shortest Path
- Word Ladder
- Word Ladder II
- Walls and Gates
- Shortest Distance from All Buildings
- The Maze
2. Connected Components / Islands / Search
- Number of Islands
- Max Area of Island
- Island Perimeter
- Battleships in a Board
- Is Graph Bipartite?
- Word Search
- Word Search II
3. Topological Sort / Dependencies
- Course Schedule
- Course Schedule II
- Alien Dictionary
4. Other Graph Problems
- Clone Graph
- Reconstruct Itinerary
- Pacific Atlantic Water Flow
- Accounts Merge
- All Nodes Distance K in Binary Tree
- Number of Connected Components in an Undirected Graph
- Minesweeper
Recommended Order
- Number of Islands
- Max Area of Island
- Island Perimeter
- Word Search
- Is Graph Bipartite?
- Course Schedule
- Course Schedule II
- Clone Graph
- Walls and Gates
- Pacific Atlantic Water Flow
- Word Ladder
- Word Ladder II
- Word Search II
- Accounts Merge
- Alien Dictionary
- Reconstruct Itinerary
Key Patterns
DFS flood-fill for connected components
BFS by layer for shortest path
topological sort for dependency ordering
union-find / graph mapping for grouping
Section 7: Stack and Queue
Recognition Signals
bracket matching
expression parsing
monotone relationships (next greater / previous smaller)
call stack simulation / time-slice modeling
Sub-categories
1. Monotone Stack / Structural Stack
- Trapping Rain Water
- Longest Valid Parentheses
2. Brackets / Calculators / Parsing
- Valid Parentheses
- Simplify Path
- Basic Calculator
- Basic Calculator II
- Basic Calculator III
- Decode String
3. Queue / Stack Simulation
- Design Circular Queue
- Exclusive Time of Functions
Recommended Order
- Valid Parentheses
- Simplify Path
- Decode String
- Basic Calculator II
- Basic Calculator
- Longest Valid Parentheses
- Trapping Rain Water
- Design Circular Queue
- Exclusive Time of Functions
- Basic Calculator III
Key Questions
do I store values or indices in the stack?
how do I compute the answer when popping?
for calculator problems: when do I "settle" the preceding expression?
Section 8: Dynamic Programming
Recognition Signals
optimal value
number of ways
can this be formed?
overlapping subproblems
Sub-categories
1. Sequence DP
- Climbing Stairs
- Fibonacci Number
- Best Time to Buy and Sell Stock
- Longest Increasing Subsequence
- Maximum Product Subarray
- Word Break
- Decode Ways
- Longest Palindromic Subsequence
2. Paths and Subarrays
- Maximum Subarray
- Unique Paths
- Unique Paths II
- Subarray Sum Equals K
- Continuous Subarray Sum
3. String / Pattern Matching
- Longest Palindromic Substring
- Regular Expression Matching
- Wildcard Matching
- Longest Increasing Path in a Matrix
Recommended Order
- Fibonacci Number
- Climbing Stairs
- Best Time to Buy and Sell Stock
- Maximum Subarray
- Unique Paths
- Unique Paths II
- Decode Ways
- Word Break
- Longest Increasing Subsequence
- Maximum Product Subarray
- Longest Palindromic Substring
- Longest Palindromic Subsequence
- Continuous Subarray Sum
- Longest Increasing Path in a Matrix
- Regular Expression Matching
- Wildcard Matching
Four-Step DP Framework
1. Define the state
2. Write the transition
3. Set base cases
4. Determine iteration order
Never skip step 1. If you don’t know what dp[i] means, everything else will be wrong.
Section 9: Heap / Top K
Recognition Signals
top k
running maximum / minimum
data stream
pop by priority
Problems
- Kth Largest Element in an Array
- K Closest Points to Origin
- Top K Frequent Elements
- Top K Frequent Words
- Reorganize String
- Find Median from Data Stream
- Kth Largest Element in a Stream
Recommended Order
- Kth Largest Element in an Array
- K Closest Points to Origin
- Top K Frequent Elements
- Kth Largest Element in a Stream
- Top K Frequent Words
- Reorganize String
- Find Median from Data Stream
Key Patterns
min-heap of size k → keep top k largest
max-heap → process highest priority first
two heaps → maintain running median
Section 10: Design
Recognition Signals
design a data structure
multiple operations must all be efficient
insert / delete / get / iterator
Problems
- LRU Cache
- Insert Delete GetRandom O(1)
- Implement Trie (Prefix Tree)
- Add and Search Word
- Design Tic-Tac-Toe
- Binary Search Tree Iterator
Recommended Order
- Implement Trie
- Binary Search Tree Iterator
- Design Tic-Tac-Toe
- Insert Delete GetRandom O(1)
- LRU Cache
- Add and Search Word
Key Steps
1. list all required operations
2. define the time complexity target for each
3. pick the combination of data structures that achieves it
Section 11: Intervals, Math, and Miscellaneous
Sub-categories
1. Intervals
- Merge Intervals
- Insert Interval
- Meeting Rooms II
Key: almost every interval problem starts with sorting by start time.
2. Math / Matrix
- Pow(x, n)
- Divide Two Integers
- Rotate Image
- Spiral Matrix
- Set Matrix Zeroes
3. Miscellaneous
- String to Integer (atoi)
- Roman to Integer
- First Missing Positive
- Longest Consecutive Sequence
- Palindrome Permutation
- Integer to English Words
- First Unique Character in a String
- Validate IP Address
- Task Scheduler
- Pancake Sorting
- Sudoku Solver
Recommended Order
- Merge Intervals
- Insert Interval
- Meeting Rooms II
- Rotate Image
- Spiral Matrix
- Set Matrix Zeroes
- Roman to Integer
- String to Integer (atoi)
- First Unique Character in a String
- Validate IP Address
- Longest Consecutive Sequence
- First Missing Positive
- Pow(x, n)
- Divide Two Integers
- Task Scheduler
- Sudoku Solver
- Integer to English Words
How to Use This List Effectively
Don’t grind problems in platform order. Use this approach instead:
Round 1: Build Templates
Do the first 3–5 problems in each section. Focus on understanding the template, not just getting AC.
Round 2: Reinforce by Pattern
Do 5–10 problems in the same pattern back-to-back. This builds automatic recognition.
Round 3: Hard Problems
Pull out the hardest problems from each section and tackle them together.
Self-Assessment System
Label each problem:
A: saw the pattern immediately, wrote it cleanlyB: got it, but not confidentC: needed hints or couldn’t solve it
Review order:
- Clear all
Cproblems first - Convert
BtoA - Maintain
Aproblems with occasional review
Must-Do Core Problems (If Time Is Limited)
If you don’t want to get overwhelmed by volume, nail these first:
- Two Sum
- Move Zeroes
- Product of Array Except Self
- 3Sum
- Longest Substring Without Repeating Characters
- Minimum Window Substring
- Search in Rotated Sorted Array
- Reverse Linked List
- Add Two Numbers
- Binary Tree Level Order Traversal
- Lowest Common Ancestor of a Binary Tree
- Subsets
- Permutations
- Number of Islands
- Course Schedule
- Valid Parentheses
- Decode String
- Climbing Stairs
- Word Break
- Kth Largest Element in an Array
- LRU Cache
- Merge Intervals
These 22 problems cover all the core templates.