Skip to content
Roadmap ยท Data Structures and Algorithms

LeetCode Patterns Roadmap: 12 Patterns, Problems to Practise and a 10-Week Plan

Younus FardeenBy Younus FardeenUpdated 1 Dec 20269 min read
Short answer

Solve LeetCode by pattern, not by random problem. Learn about twelve patterns, such as hash map, two pointers, sliding window, binary search, tree and graph traversal, backtracking, heap and 1D dynamic programming. For each, study one template, solve three problems, then re-solve them from memory after a few days. No fixed problem count guarantees an offer.

On this pageWhy patterns, and how many problems is enoughThe 12 patterns: signal words, template and problemsA 10-week scheduleHow to solve a LeetCode problem, and how to reviewFrequently asked questions

This roadmap is for students who open LeetCode, solve a few problems, forget them, and feel they are not improving. The fix is to group problems by the idea that solves them, so each new problem looks like an old one.

The 36 problems below are real LeetCode problems. Number, title and difficulty were checked against LeetCode's own site on 1 December 2026. The page does not claim that any number of problems leads to any result, and says why in the section on counts.

  1. 1
    FoundationsArrays, hash map, complexity
  2. 2
    Pointers and windowsTwo pointers, sliding window
  3. 3
    Search and stackBinary search, stack
  4. 4
    Trees and graphsDFS, BFS, grids
  5. 5
    Recursion familyBacktracking, 1D DP
  6. 6
    Heaps and greedyTop k, intervals
  7. 7
    Mixed reviewTimed sets, mock rounds
The order the patterns are learned in the 10-week plan.

Why patterns, and how many problems is enough

A pattern is a reusable shape of solution: a loop structure and a data structure that fit a family of problems. "Longest substring with a condition" is a sliding window; "fewest moves" is BFS. If you can name the pattern within a minute of reading, you start from a template instead of a blank page.

On how many problems to solve: no verified number exists. Candidates differ in background, target companies and how well they retain what they solved, and LeetCode does not publish a pass mark. This plan uses 36 core problems, three per pattern, and judges progress by something you can test: can you solve a new problem of the same pattern, from a blank file, in 30 to 40 minutes? Twenty problems you can re-solve cold beat a hundred you read the solution for.

If you are earlier than this, begin with the DSA learning path. The time complexity page is the one prerequisite, since every pattern here is justified by complexity.

The 12 patterns: signal words, template and problems

Read the signal words in the problem statement first. They are the cheapest clue. The template column is the shape of the loop, not a full solution. Problem numbers are LeetCode's; difficulties are in brackets (E easy, M medium, H hard).

PatternSignal wordsTemplateThree problems to practise
1. Hash map and prefix sumpair, count, duplicate, subarray sum equalsStore seen values or running totals in a dict, look up the complement1 Two Sum (E); 560 Subarray Sum Equals K (M); 238 Product of Array Except Self (M)
2. Two pointerssorted, pair, triplet, palindrome, in placePointers at both ends, move the one that can improve the answer125 Valid Palindrome (E); 11 Container With Most Water (M); 15 3Sum (M)
3. Sliding windowlongest, shortest, contiguous, at most kGrow right edge, shrink left while invalid3 Longest Substring Without Repeating Characters (M); 209 Minimum Size Subarray Sum (M); 76 Minimum Window Substring (H)
4. Binary searchsorted, rotated, minimum speed or capacity, O(log n)lo, hi, mid; search an index or the answer itself704 Binary Search (E); 33 Search in Rotated Sorted Array (M); 875 Koko Eating Bananas (M)
5. Fast and slow pointers (linked list)cycle, middle, kth from endslow moves 1, fast moves 2, or reverse links as you walk141 Linked List Cycle (E); 876 Middle of the Linked List (E); 206 Reverse Linked List (E)
6. Stack and monotonic stackmatching, next greater, nested, undoPush, pop while the top breaks the rule20 Valid Parentheses (E); 739 Daily Temperatures (M); 84 Largest Rectangle in Histogram (H)
7. Tree DFS and BFSbinary tree, depth, level, ancestorRecursion on left and right, or a queue per level104 Maximum Depth of Binary Tree (E); 102 Binary Tree Level Order Traversal (M); 236 Lowest Common Ancestor of a Binary Tree (M)
8. Graph and grid BFS/DFSislands, connected, shortest moves, reachableSeen set plus queue or stack over neighbours200 Number of Islands (M); 133 Clone Graph (M); 994 Rotting Oranges (M)
9. Backtrackingall combinations, permutations, subsets, generateChoose, recurse, undo the choice78 Subsets (M); 46 Permutations (M); 39 Combination Sum (M)
10. Heap and top kkth largest, top k, median, merge kMin-heap of size k, or two heaps215 Kth Largest Element in an Array (M); 347 Top K Frequent Elements (M); 295 Find Median from Data Stream (H)
11. 1D dynamic programmingways to, minimum cost, can reach, choose or skipdp[i] from earlier dp values; base cases first70 Climbing Stairs (E); 198 House Robber (M); 322 Coin Change (M)
12. Intervals and greedymerge, overlap, schedule, jump, best timeSort by start or end, then one sweep keeping a running best56 Merge Intervals (M); 55 Jump Game (M); 121 Best Time to Buy and Sell Stock (E)

Deep dives on the harder rows: two pointers and sliding window with ten solved problems, BFS vs DFS for rows 7 and 8, backtracking for row 9, heaps for row 10 and dynamic programming for row 11.

One template made concrete: binary search on the answer

Row 4 hides the template people miss. When the question asks for the smallest value that satisfies a condition, and the condition flips from false to true once, you binary search the value, not an array. This is LeetCode 875: find the slowest eating speed that finishes all piles within the hours.

def min_speed(piles, hours):
    """Smallest eating speed k so every pile is finished within `hours`."""
    def can_finish(k):
        return sum(-(-p // k) for p in piles) <= hours   # ceiling division

    lo, hi = 1, max(piles)
    while lo < hi:                       # search the ANSWER, not an array index
        mid = (lo + hi) // 2
        if can_finish(mid):
            hi = mid                     # mid works: try something smaller
        else:
            lo = mid + 1                 # mid is too slow: go bigger
    return lo

print(min_speed([3, 6, 7, 11], 8))
print(min_speed([30, 11, 23, 4, 20], 5))
print(min_speed([30, 11, 23, 4, 20], 6))

The three lines print 4, 30 and 23. The same lo, hi, mid skeleton reappears in capacity, split array and minimum-days problems. See binary search explained for the array version.

A 10-week schedule

The plan assumes about 6 to 8 hours a week and four to six problems a week. That pace is a suggestion for a student with classes, not a measured requirement. If a week slips, repeat it rather than skipping it.

WeekPatternsWork this weekEnd-of-week check
11. Hash map and prefix sumRead the complexity page. Solve the 3 problems. Write the dict template from memory.Solve 1 Two Sum cold in 10 minutes
22. Two pointers, 3. Sliding windowRead the two pointers page. Solve the 6 problems (76 can wait until week 10 if stuck).Say which pattern applies before coding
34. Binary search, 5. Linked list pointersDo the 6 problems. Draw pointer moves on paper for the linked list ones.Re-solve week 1 problems
46. StackDo the 3 problems and add 1 extra easy stack problem.Re-solve week 2 problems
57. Tree DFS and BFSDo the 3 problems. Write recursion with a stated base case.Re-solve week 3 problems
68. Graph and gridRead BFS vs DFS. Do the 3 problems.Re-solve week 4 problems
79. BacktrackingDo the 3 problems. Draw the decision tree for each.Re-solve week 5 problems
810. Heap and top k, 11. 1D dynamic programmingDo the 6 problems. For DP, write the recurrence in words first.Re-solve week 6 problems
912. Intervals and greedy, plus 743 Network Delay TimeDo the 3 problems, then read the Dijkstra page and try 743 as a stretch.Re-solve week 7 problems
10Mixed reviewTwo timed sets of 3 unseen medium problems, 40 minutes each, chosen without looking at the topic.Write the pattern you missed and why

That is 36 core problems across ten weeks, plus re-solves. For a company-style question list after week 10, use DSA interview questions, and for contest-style practice the competitive programming roadmap.

How to solve a LeetCode problem, and how to review

A routine for each problem

  1. Read it twice. Write the input size and any sorted or positive hints.
  2. Name the pattern from the signal words. If nothing fits, write the brute force first and find its repeated work.
  3. State the complexity of the brute force and the target. The input limits tell you the target.
  4. Code the template. Run the examples by hand before pressing submit.
  5. Cap the struggle at 30 to 40 minutes. Then read one hint, not the full solution, and try again.
  6. After solving, write one line: pattern, the key insight, the mistake you made.

Review schedule that is actually testable

WhenWhat to doPass means
Same dayRe-type the solution without lookingIt runs and matches your notes
Day 3Solve again from a blank fileNo hints, within 20 minutes
Day 10Solve a different problem of the same patternYou named the pattern before coding
Day 30Mixed set of 3 patterns, timedAt least 2 of 3 solved in time

Keep the log in a plain table with problem, pattern, date, result and the mistake. Patterns you fail twice go to the top of next week's list. Platforms and free sites to practise on are listed in the coding practice websites guide.

Mistakes that waste weeks

  • Reading solutions after five minutes. You only learn the pattern if you struggled with the problem first.
  • Doing problems in order of the LeetCode list, which mixes patterns at random.
  • Solving each problem once. Without repeats, most of the learning fades.
  • Skipping the brute force. It is the fallback in an interview and the key to seeing the optimisation.
  • Counting problems instead of patterns you can solve cold.

Frequently asked questions

How many LeetCode problems should I solve?

There is no verified number that guarantees anything. A practical target is about three problems per pattern across twelve patterns, so 36 core problems, and being able to re-solve each from a blank file. Quality of review matters more than the count, since two attempts on one problem teach more than two shallow passes.

How do I start LeetCode as a beginner?

Start with easy problems in one pattern at a time: hash map, then two pointers. Learn big-O first so you can judge your solution. Cap each attempt at 30 to 40 minutes, read one hint if stuck, and re-solve after three days. Skip hard problems until you can do mediums in a topic.

What are the most important LeetCode patterns?

Hash map, two pointers, sliding window, binary search, stack, tree and graph traversal with BFS and DFS, backtracking, heaps and 1D dynamic programming appear again and again in interview question lists. This page uses twelve patterns. Which ones a particular company asks most is not published, so cover all twelve.

Is LeetCode enough to crack coding interviews?

It is the most common practice source, but not the only skill. Interviews also test explaining your approach, handling follow-ups and basic design for some roles. Practising aloud and doing timed mocks help. Nothing guarantees an outcome, so treat problem practice as one part of preparation.

How long does it take to learn LeetCode patterns?

The 10-week plan here assumes 6 to 8 hours a week and four to six problems weekly. Some people need longer to retain recursion and dynamic programming. If a pattern fails the day-3 re-solve, repeat the week rather than moving on.

Should I memorise solutions or understand them?

Understand the pattern and re-derive the code. Memorised solutions fail when a problem changes slightly. A good test is to explain why each line exists and to solve a variation, such as the average version of a window sum, without looking.

Which language should I use on LeetCode?

Use the one you know best and can write fast and correctly. Python is compact and common for interviews; Java and C++ are also accepted. Pick one, learn its standard library for heaps, queues and dictionaries, and stay with it through the 10 weeks.

Learn this with mentors

Programmes for builders and engineers with admissions open: live classes, mentors and project work.

Continue learning

Interview prep

DSA interview questions

14 patterns with Python code, 40 problems, a six-week plan and company notes

11 min read
Roadmap

Competitive programming roadmap

Platforms, India pathway, a 6-month plan and what it means for jobs

10 min read
Concept

Two pointers and sliding window

Five problems each, brute force next to optimised code, with signal words

8 min read