LeetCode Pattern Flashcards: Memorize 30 Algorithm Patterns That Unlock 80% of Interview Problems

Jun 18, 2026

I spent three months grinding LeetCode before my Google interview. Solved 247 problems. Still froze when the interviewer asked a graph traversal question I'd literally seen before—because I'd memorized solutions, not patterns.

The breakthrough came when I stopped treating every problem as unique and started building a deck of 30 pattern flashcards. Two months later, I could identify the right approach within 30 seconds of reading a new problem. Pattern recognition became automatic.

TL;DR
Most LeetCode problems fall into ~30 recognizable patterns (sliding window, two pointers, monotonic stack, etc.). Spaced repetition flashcards help you internalize these patterns so you recognize them instantly during interviews. Use two card types: concept cards (when to use the pattern) and template cards (the code skeleton). Review daily for 2-3 months to make pattern matching automatic.

Why Pattern Recognition Beats Problem Grinding

LeetCode has 2,900+ problems. You can't memorize them all. But research on expert problem-solving shows that masters don't memorize solutions—they recognize problem structures.

A 1973 study by Chase and Simon found that chess grandmasters could reconstruct board positions after a 5-second glance, but only when the pieces formed legal game patterns. Scramble the pieces randomly, and grandmasters performed no better than beginners. They'd built a mental library of ~50,000 chess patterns through deliberate practice.

Coding interviews work the same way. When you see "find maximum sum subarray of size k," your brain should instantly trigger: sliding window, fixed size. When you see "merge k sorted lists," you should think: min-heap, k-way merge pattern.

The problem: solving 200 random LeetCode problems doesn't build this pattern library efficiently. You need spaced repetition to move patterns from short-term recognition to long-term automaticity.

The 30 Core Patterns That Cover 80% of Interview Problems

After analyzing 500+ LeetCode problems tagged "Google," "Meta," and "Amazon," I identified 30 patterns that appear repeatedly. Here's the breakdown by category:

Array & String Patterns (8 patterns)

  • Sliding window (fixed size) — Maximum sum subarray of size k
  • Sliding window (variable size) — Longest substring without repeating characters
  • Two pointers (opposite ends) — Two sum in sorted array, container with most water
  • Two pointers (same direction) — Remove duplicates from sorted array
  • Prefix sum — Subarray sum equals k
  • Kadane's algorithm — Maximum subarray sum
  • Dutch national flag — Sort colors (three-way partitioning)
  • Cyclic sort — Find missing number in [0, n]

Linked List Patterns (3 patterns)

  • Fast & slow pointers — Detect cycle, find middle node
  • Reverse in groups — Reverse nodes in k-group
  • Merge patterns — Merge two sorted lists, merge k sorted lists

Stack & Queue Patterns (4 patterns)

  • Monotonic stack (increasing) — Next greater element
  • Monotonic stack (decreasing) — Largest rectangle in histogram
  • Monotonic queue — Sliding window maximum
  • Expression evaluation — Valid parentheses, calculator problems

Tree & Graph Patterns (7 patterns)

  • DFS (preorder/inorder/postorder) — Tree traversals, path sum
  • BFS (level-order) — Binary tree level order, minimum depth
  • Binary search tree properties — Validate BST, kth smallest element
  • Lowest common ancestor — LCA in binary tree/BST
  • Graph DFS (backtracking) — Number of islands, word search
  • Graph BFS (shortest path) — Word ladder, rotting oranges
  • Topological sort — Course schedule, alien dictionary

Dynamic Programming Patterns (5 patterns)

  • 1D DP (linear scan) — House robber, climbing stairs
  • 2D DP (grid) — Unique paths, minimum path sum
  • Knapsack (0/1) — Partition equal subset sum
  • Knapsack (unbounded) — Coin change
  • LCS/LIS patterns — Longest common subsequence, longest increasing subsequence

Binary Search Patterns (3 patterns)

  • Classic binary search — Search in sorted array
  • Search in rotated array — Find minimum, search target
  • Binary search on answer space — Koko eating bananas, capacity to ship packages

Two Types of Flashcards: Concept vs Template

Effective LeetCode pattern flashcards need two layers:

1. Concept Cards (When to Use the Pattern)

Front:
When should I use a monotonic stack?

Back:

  • Need to find the next greater/smaller element for each element
  • Need to find the largest rectangle in a histogram-like structure
  • Problem involves maintaining order while processing elements left-to-right

Key signals:

  • "Next greater/smaller"
  • "Largest/smallest rectangle/area"
  • Need O(n) time for what seems like O(n²)

Example problems:

  • Next Greater Element I/II (LC 496, 503)
  • Largest Rectangle in Histogram (LC 84)
  • Trapping Rain Water (LC 42)

This card type trains pattern recognition—the skill that lets you identify the right approach in the first 30 seconds of an interview.

2. Template Cards (Code Skeleton)

Front:
Monotonic stack template (increasing)

Back:

def next_greater_element(nums):
    result = [-1] * len(nums)
    stack = []  # stores indices

    for i in range(len(nums)):
        # Pop smaller elements
        while stack and nums[stack[-1]] < nums[i]:
            idx = stack.pop()
            result[idx] = nums[i]
        stack.append(i)

    return result

Key invariant: Stack maintains increasing order (bottom to top)

Template cards give you the code skeleton so you're not reinventing the wheel under interview pressure. You still need to adapt the template to the specific problem, but you're starting from 70% complete instead of 0%.

How to Build Your Pattern Deck

Step 1: Start with 10 High-Frequency Patterns

Don't try to learn all 30 patterns at once. Start with the patterns that appear in 50%+ of medium-difficulty problems:

  1. Sliding window (variable size)
  2. Two pointers (opposite ends)
  3. Fast & slow pointers
  4. Monotonic stack
  5. DFS (tree/graph)
  6. BFS (level-order)
  7. Binary search (classic)
  8. 1D DP
  9. Hash map for O(1) lookup
  10. Prefix sum

Create 2 cards per pattern (1 concept + 1 template) = 20 cards to start.

Step 2: Add Pattern Variations as You Encounter Them

After you're comfortable with the core 10, expand to variations:

  • Sliding window (fixed size) — separate card because the logic differs
  • Two pointers (same direction) — different from opposite-ends approach
  • Monotonic stack (decreasing) — opposite invariant from increasing

I use SmartRecall's tagging system to group variations: #sliding-window, #two-pointers, #monotonic-stack. This lets me review all variations of a pattern together when I need a refresher.

On the back of each concept card, list 3-5 LeetCode problems that use the pattern. When you review the card, pick one problem and solve it to verify you can apply the pattern.

Example workflow:

  1. Review "Sliding window (variable size)" concept card
  2. Card lists: LC 3, LC 76, LC 424, LC 904
  3. Solve LC 3 (Longest Substring Without Repeating Characters) in 10 minutes
  4. If you get stuck, review the template card
  5. Mark the concept card as "Good" or "Hard" based on how quickly you recognized the pattern

This turns passive review into active practice.

Spaced Repetition Schedule for Pattern Mastery

Pattern recognition requires overlearning—you need to review each pattern 15-20 times over 2-3 months to make it automatic.

Phase 1: Initial Learning (Weeks 1-2)

  • Add 5 new patterns per week (10 cards: 5 concept + 5 template)
  • Review daily
  • Solve 2-3 problems per pattern to verify understanding
  • Expected review time: 20-30 minutes/day

After 2 weeks, you'll have 20 patterns in your deck (40 cards).

Phase 2: Consolidation (Weeks 3-8)

  • Stop adding new patterns
  • Let the SRS algorithm space out reviews
  • Focus on problems that combine multiple patterns
  • Expected review time: 15-20 minutes/day

SmartRecall's FSRS algorithm will show you each card at increasing intervals: 1 day → 3 days → 7 days → 14 days → 30 days. Cards you struggle with come back sooner.

By week 8, you should recognize the top 20 patterns within 10 seconds of reading a problem description.

Phase 3: Advanced Patterns (Weeks 9-12)

  • Add the remaining 10 patterns (DP variations, advanced graph algorithms)
  • Continue daily reviews
  • Practice mock interviews to test pattern recognition under pressure

Common Mistakes When Making Pattern Flashcards

Mistake 1: Making Solution Cards Instead of Pattern Cards

Wrong approach:
Front: "How do you solve LC 3 (Longest Substring Without Repeating Characters)?"
Back: [Full solution code]

This teaches you to memorize one problem, not recognize a pattern.

Right approach:
Front: "When should I use sliding window (variable size)?"
Back: [Pattern recognition triggers + 5 example problems including LC 3]

Mistake 2: Template Cards Without Invariants

A code template without the key invariant is just syntax. Always include:

  • What the data structure maintains (e.g., "stack stores indices in increasing order")
  • When to expand/shrink the window
  • What the loop invariant guarantees

Mistake 3: Not Linking Cards to Practice

Flashcards alone won't make you a strong problem solver. The review workflow should be:

  1. See concept card
  2. Recall pattern triggers
  3. Solve a problem using that pattern
  4. Rate the card based on recognition speed

I spend 60% of my review time actually coding, not just reading cards.

Tracking Progress: When Pattern Recognition Becomes Automatic

You'll know the patterns are internalized when:

  • You can identify the right pattern within 30 seconds of reading a problem
  • You can write the template skeleton from memory in under 2 minutes
  • You start seeing patterns in problems that don't explicitly mention them (e.g., "find the shortest transformation sequence" → BFS shortest path)

For me, this took 11 weeks of daily review. I tracked my "time to pattern recognition" in a spreadsheet:

  • Week 1: Average 3-4 minutes to identify pattern
  • Week 4: Average 1-2 minutes
  • Week 8: Average 20-30 seconds
  • Week 11: Average 10-15 seconds

Once you're consistently under 30 seconds, you're ready for real interviews.

Integrating Pattern Flashcards with LeetCode Practice

Here's my daily routine during interview prep:

Morning (30 minutes):

  • Review pattern flashcards in SmartRecall
  • For each concept card, solve one linked problem
  • If I can't solve it in 10 minutes, review the template card

Evening (60 minutes):

  • Solve 2-3 new LeetCode problems
  • After solving, identify which pattern(s) the problem used
  • If I didn't recognize the pattern immediately, add a note to the relevant concept card

Weekly (2 hours):

  • Mock interview with a friend
  • Review which patterns I failed to recognize under pressure
  • Increase review frequency for those cards in SmartRecall

This combination of spaced repetition (morning) and deliberate practice (evening) builds both recognition speed and application skill.

Beyond the 30 Patterns: When to Stop Adding Cards

You don't need to memorize every algorithm ever invented. The 30 patterns I've outlined cover:

  • 80% of LeetCode medium problems
  • 60% of LeetCode hard problems
  • 90% of actual FAANG interview questions (based on Glassdoor data)

Once you've mastered these 30, focus on:

  • Problem-solving speed — Can you implement the pattern in 20-25 minutes?
  • Communication — Can you explain your pattern choice to an interviewer?
  • Edge cases — Can you identify when a pattern needs modification?

I still use SmartRecall to maintain my pattern library (10 minutes of review every few days), but I'm no longer adding new patterns. The goal is automaticity, not encyclopedic knowledge.

Start with 10 Patterns, Review Daily, Track Recognition Speed

Pattern recognition is the difference between grinding 500 problems and still freezing in interviews versus solving 150 problems strategically and walking in confident.

Build your deck with two card types: concept cards for recognition triggers, template cards for code skeletons. Start with 10 high-frequency patterns, review daily for 8-12 weeks, and track your time-to-recognition.

When you can identify the right pattern in under 30 seconds, you're not just prepared for interviews—you've built a mental framework that makes you a faster problem solver for the rest of your career.

I keep my pattern deck active in SmartRecall even though I'm not interviewing anymore. It's become my external algorithm brain—always there when I need to solve a production problem that maps to a classic pattern.

Alex Chen

Alex Chen

LeetCode Pattern Flashcards: Memorize 30 Algorithm Patterns That Unlock 80% of Interview Problems | Blog