LeetCode Strategy: How to Solve 100 Problems Without Going Crazy
A practical LeetCode strategy guide — learn which patterns to study, how to practice effectively, and how to use LeetCode to prepare for real coding interviews without burning out.
Get more content like this on Telegram!
Daily AI tips, notes & resources — free
LeetCode Strategy: How to Solve 100 Problems Without Going Crazy
Three months before a senior engineer interview at a company I really wanted to join, I started grinding LeetCode. My plan: solve every problem from Easy to Hard in order.
After 60 days, I had solved 180 problems. I felt confident. Then I walked into the interview and blanked on a medium-difficulty graph problem I'd definitely seen variations of before.
The problem wasn't that I hadn't practiced enough. It was that I'd practiced the wrong way — accumulating problem counts instead of learning patterns. I could solve problems I'd seen before but couldn't transfer that knowledge to novel problems.
I didn't get that offer. I spent two more months studying differently, got another interview, and got the offer. In this guide, you'll learn the strategy that actually works — the one I wish I'd known from the start.
The Core Insight: Patterns, Not Problems
There are tens of thousands of LeetCode problems. You cannot memorize all of them. You don't need to.
Most coding problems are variations on about 15 fundamental patterns. If you recognize that a problem is a "sliding window" problem, you already know 80% of the solution. If you recognize it's BFS on a graph, you know exactly what to code.
The goal of LeetCode practice isn't to solve problems — it's to recognize patterns so you can solve problems you've never seen.
Analogy: Learning chess openings. You don't memorize every possible game. You learn 5–10 opening patterns and can improvise from there.
The 15 Patterns That Cover 80% of Interviews
Pattern 1: Two Pointers
Use when: array or string problem where you need to compare or process pairs of elements.
// Classic: check if a sorted array has two numbers that sum to target
function twoSum(sortedArray, target) {
let left = 0, right = sortedArray.length - 1;
while (left < right) {
const sum = sortedArray[left] + sortedArray[right];
if (sum === target) return [left, right];
else if (sum < target) left++;
else right--;
}
return [];
}
Recognizable by: sorted arrays, finding pairs, comparing elements from both ends.
Pattern 2: Sliding Window
Use when: finding a subarray or substring with a given property.
// Maximum sum subarray of size k
function maxSumSubarray(arr, k) {
let windowSum = 0, maxSum = 0;
for (let i = 0; i < k; i++) windowSum += arr[i];
maxSum = windowSum;
for (let i = k; i < arr.length; i++) {
windowSum += arr[i] - arr[i - k]; // Slide: add new, remove old
maxSum = Math.max(maxSum, windowSum);
}
return maxSum;
}
Recognizable by: "subarray of size k", "longest substring with no more than X distinct characters", "minimum window containing all characters."
Pattern 3: BFS (Breadth-First Search)
Use when: finding the shortest path, or processing nodes level by level.
// BFS traversal of a binary tree level by level
function levelOrder(root) {
if (!root) return [];
const result = [];
const queue = [root];
while (queue.length > 0) {
const levelSize = queue.length;
const level = [];
for (let i = 0; i < levelSize; i++) {
const node = queue.shift();
level.push(node.val);
if (node.left) queue.push(node.left);
if (node.right) queue.push(node.right);
}
result.push(level);
}
return result;
}
Pattern 4: DFS (Depth-First Search)
Use when: tree/graph traversal, finding paths, backtracking problems.
// Check if a path exists in a binary tree summing to target
function hasPathSum(root, target) {
if (!root) return false;
if (!root.left && !root.right) return root.val === target;
return hasPathSum(root.left, target - root.val) ||
hasPathSum(root.right, target - root.val);
}
Pattern 5: Dynamic Programming
Use when: optimization problem with overlapping subproblems (often "maximum/minimum", "number of ways to").
// Fibonacci with memoization (DP)
function fib(n, memo = {}) {
if (n in memo) return memo[n];
if (n <= 1) return n;
memo[n] = fib(n - 1, memo) + fib(n - 2, memo);
return memo[n];
}
These 5 patterns alone cover roughly 50% of interview problems. The full 15 patterns are documented in resources like the "Grokking the Coding Interview" course and the Blind 75 curated problem list.
The Study System That Works
Phase 1: Pattern Learning (Weeks 1–4)
Pick one pattern per week. Solve 5–10 problems in that pattern, understanding each solution deeply:
Week 1: Two Pointers + Sliding Window
- LeetCode 1 (Two Sum), 167 (Two Sum II), 15 (3Sum)
- LeetCode 209 (Minimum Size Subarray), 3 (Longest Substring Without Repeat)
Week 2: Tree BFS + DFS
- LeetCode 102 (Level Order Traversal), 112 (Path Sum), 104 (Max Depth)
Week 3: Dynamic Programming basics
- LeetCode 70 (Climbing Stairs), 198 (House Robber), 5 (Longest Palindromic Substring)
Week 4: Binary Search + Fast/Slow Pointers
- LeetCode 704 (Binary Search), 33 (Search in Rotated Array), 141 (Linked List Cycle)
Phase 2: Pattern Application (Weeks 5–8)
Solve new problems cold (without hints). Your goal: identify the pattern within 5 minutes of reading the problem.
For each problem you solve:
- Read the problem
- Identify the pattern (out loud or written)
- Code the solution
- Compare to optimal solution
- Write a 1-sentence note: "This is [pattern] because [signal]"
Phase 3: Review and Reinforce (Weeks 9–12)
Revisit problems you solved in Phase 1 — without looking at your previous solution. If you can't solve it independently, that's the problem to spend more time on.
The 25-Minute Rule
Set a 25-minute timer when you start a problem. If after 25 minutes you have:
- A working solution → great, check for optimization
- A partial approach → keep going for 15 more minutes
- No meaningful progress → look at the hint or solution category
The reason: if you've been stuck for 25 minutes without progress, you're missing a concept or technique. Spending another hour won't fix that — learning the missing concept will.
This rule prevents the most common LeetCode mistake: spending 4 hours on one problem and learning nothing.
How to Review Solutions Effectively
Looking at a solution you couldn't solve is only valuable if you extract the pattern:
After looking at solution for "Minimum Window Substring":
Pattern: Sliding Window with two pointers
Signal: "minimum subarray/substring containing [condition]"
Key technique: use a hash map to track character frequency in the window
When window satisfies condition: shrink from left
When window doesn't satisfy: expand to right
Similar problems: Fruit Into Baskets, Longest Substring with K Distinct Characters
This pattern note is more valuable than the code itself. Next time you see "minimum substring containing all characters," you'll recognize the pattern immediately.
Common Mistakes and How to Avoid Them
Mistake 1: Solving too many problems, understanding too few Fix: Solve 3 problems deeply instead of 10 problems shallowly.
Mistake 2: Always using hints after 10 minutes Fix: Use the 25-minute rule. Struggle builds pattern recognition.
Mistake 3: Not reviewing past problems Fix: Schedule weekly reviews. Spaced repetition works.
Mistake 4: Grinding Hard problems too early Fix: Nail Easy and Medium first. Hard problems rarely appear in standard interviews.
Mistake 5: Measuring progress by problem count Fix: Measure by patterns mastered and "cold solve" success rate.
Recommended Problem List
The Blind 75 (curated by a Blind.com engineer) covers the most important problems across all patterns. The NeetCode 150 extends this with better coverage of DP and graphs. Start with the Blind 75.
For data structures knowledge to support your LeetCode practice, our data structures guide covers arrays, trees, graphs, and hash maps with practical examples.
Frequently Asked Questions
How many LeetCode problems do I need to pass a coding interview?
100–200 problems solved intentionally by pattern is more effective than 300+ solved randomly. Focus on Easy and Medium, understand the pattern behind each solution.
What are the most important LeetCode patterns?
Two Pointers, Sliding Window, BFS, DFS, and Dynamic Programming cover 50%+ of problems. The full 15 patterns cover 80%+ of interview questions.
Should I solve problems in order of difficulty?
No — solve by pattern. Working through all "Two Pointers" problems builds pattern recognition faster than Easy→Medium→Hard random order.
I understand solutions but can't solve problems myself. What do I do?
Close the solution, wait 24 hours, try again from memory. Then solve a similar problem cold. Struggle is where actual learning happens.
How do I practice without burning out?
The 25-minute rule: look at hints after 25 minutes of no progress. Practice in 45–60 minute daily sessions. Consistency beats weekend marathons.
Frequently Asked Questions
AiTechWorlds Team
✓ Verified WriterThe AiTechWorlds team is passionate about AI, technology, and education. We create high-quality, research-backed content to help you learn, grow, and succeed in the modern digital world.
Related Articles
15 Coding Habits That Separate Senior Developers from Juniors
Discover the coding habits senior developers follow every day — from writing readable code to debugging smarter — that separate pros from beginners.
The 10 VS Code Extensions That Make You Code Twice as Fast
The best VS Code extensions in 2025 that genuinely boost productivity — from AI code completion to live sharing, error highlighting, and formatting automation.
Terminal and Command Line Mastery: 30 Commands That Changed My Life
Learn essential terminal commands for developers — navigation, file operations, git, process management, and shell shortcuts that make you dramatically faster at the command line.
Data Structures for Humans: Finally Understanding Arrays, Trees, Graphs
Data structures explained simply for beginners — learn arrays, linked lists, stacks, queues, trees, and graphs with real-world analogies and practical code examples.