Skip to main content
    Technical Prep

    Coding Interview Patterns: 15 Patterns That Cover 80% of Problems

    Stop grinding random LeetCode problems. There are 15 recurring patterns behind almost every coding interview question, and once you learn them, everything clicks.

    March 10, 2026
    7 min read
    21 views
    Craqly Team
    Coding Interview Patterns: 15 Patterns That Cover 80% of Problems
    coding interview
    leetcode patterns
    algorithm patterns
    data structures
    technical interview

    Why Random Grinding Doesn't Work

    I spent three months doing random LeetCode problems before my Google interview. Solved about 200 of them. Got to the interview and froze on a problem I'd never seen before. Failed.

    Here's what I wish someone had told me: you don't need to solve 500 problems. You need to recognize 15 patterns. Once you see the pattern behind a problem, the solution almost writes itself. A friend of mine solved maybe 80 problems total but nailed interviews at Amazon and Microsoft — because he studied patterns, not individual questions.

    These 15 patterns cover roughly 80% of what you'll encounter. I'm listing them in the order I'd recommend studying them.

    Pattern 1: Two Pointers

    What it is: Use two pointers that move toward each other (or in the same direction) to solve problems on sorted arrays or linked lists.

    When to use it: Any time you're working with a sorted array and need to find pairs, triplets, or subarrays matching some condition.

    Example problem: Two Sum II (sorted input), 3Sum, Remove Duplicates from Sorted Array.

    Start here. It's the easiest pattern to grasp, and you'll use the mental model constantly.

    Pattern 2: Sliding Window

    What it is: Maintain a "window" of elements as you scan through an array or string, expanding or shrinking the window based on conditions.

    When to use it: Problems asking for the longest/shortest substring or subarray meeting some constraint. If you see "contiguous subarray" or "substring," think sliding window immediately.

    Example problem: Longest Substring Without Repeating Characters, Minimum Window Substring, Maximum Sum Subarray of Size K.

    Pattern 3: Fast & Slow Pointers

    What it is: Two pointers moving at different speeds through a sequence. Classic tortoise-and-hare approach.

    When to use it: Cycle detection in linked lists, finding the middle of a linked list, or determining if a number is "happy."

    Example problem: Linked List Cycle, Find the Duplicate Number, Happy Number.

    Pattern 4: Merge Intervals

    What it is: Sort intervals by start time, then merge overlapping ones by comparing each interval's start with the previous interval's end.

    When to use it: Scheduling problems, overlapping ranges, anything involving time slots or ranges on a number line.

    Example problem: Merge Intervals, Insert Interval, Meeting Rooms II.

    This one comes up in system design too. Knowing it cold is worth the time.

    Pattern 5: Cyclic Sort

    What it is: When you have an array with numbers in a known range (1 to N), place each number at its correct index in a single pass.

    When to use it: Finding missing numbers, duplicates, or the first missing positive in an array of integers in range [1, N].

    Example problem: Find All Numbers Disappeared in an Array, Find the Duplicate Number, First Missing Positive.

    Pattern 6: In-Place Linked List Reversal

    What it is: Reverse a linked list (or a portion of it) by manipulating node pointers directly without extra memory.

    When to use it: Any problem that asks you to reverse a linked list, reverse a sublist, or reverse nodes in groups.

    Example problem: Reverse Linked List, Reverse Linked List II, Reverse Nodes in k-Group.

    Pattern 7: BFS (Breadth-First Search)

    What it is: Explore nodes level by level using a queue. Process all nodes at the current depth before moving deeper.

    When to use it: Shortest path in unweighted graphs, level-order tree traversal, anything that asks for "minimum steps" or "nearest."

    Example problem: Binary Tree Level Order Traversal, Rotting Oranges, Word Ladder.

    If the problem mentions "shortest" or "minimum" in a graph context, BFS is almost always the answer.

    Pattern 8: DFS (Depth-First Search)

    What it is: Explore as deep as possible along each branch before backtracking. Uses recursion or an explicit stack.

    When to use it: Tree traversals, graph connectivity, path-finding where you need ALL paths, island counting on grids.

    Example problem: Number of Islands, Path Sum, Clone Graph.

    Pattern 9: Two Heaps

    What it is: Maintain a max-heap and a min-heap simultaneously to efficiently track the median or balance two halves of a dataset.

    When to use it: Finding the running median, balancing two groups, or any problem where you need quick access to both the largest of the small half and the smallest of the large half.

    Example problem: Find Median from Data Stream, Sliding Window Median.

    This pattern trips people up because most developers rarely use heaps day-to-day. Practice implementing it from scratch at least twice.

    Pattern 10: Subsets & Permutations

    What it is: Generate all possible subsets, permutations, or combinations using backtracking — add an element, recurse, then remove it.

    When to use it: Problems asking for "all possible" arrangements, combinations, power sets, or letter case permutations.

    Example problem: Subsets, Permutations, Combination Sum, Letter Case Permutation.

    Pattern 11: Modified Binary Search

    What it is: Standard binary search adapted for tricky conditions — rotated arrays, unknown-size arrays, or finding boundaries rather than exact matches.

    When to use it: Sorted or partially sorted arrays. If you see O(log n) in the expected complexity, it's binary search.

    Example problem: Search in Rotated Sorted Array, Find Minimum in Rotated Sorted Array, Search a 2D Matrix.

    Pattern 12: Top K Elements

    What it is: Use a heap (usually a min-heap of size K) to efficiently find the K largest, smallest, or most frequent elements.

    When to use it: "Find top K," "K most frequent," "Kth largest" — any problem with K in the title, basically.

    Example problem: Top K Frequent Elements, Kth Largest Element in an Array, K Closest Points to Origin.

    Pattern 13: K-Way Merge

    What it is: Merge K sorted lists using a min-heap that always holds one element from each list. Pull the smallest, push the next element from that list.

    When to use it: Merging sorted arrays/lists, finding the smallest range covering elements from K lists.

    Example problem: Merge K Sorted Lists, Smallest Range Covering Elements from K Lists, Kth Smallest Number in M Sorted Lists.

    Pattern 14: Dynamic Programming

    What it is: Break a problem into overlapping subproblems and store results to avoid recomputation. Bottom-up (tabulation) or top-down (memoization).

    When to use it: Optimization problems ("minimum cost," "maximum profit," "number of ways"), problems with optimal substructure. If brute force involves exponential recursion, DP probably applies.

    Example problem: Climbing Stairs, Coin Change, Longest Common Subsequence, 0/1 Knapsack.

    Honestly, DP is where most people struggle. Don't try to learn all DP problems. Focus on these sub-patterns: Fibonacci-type, 0/1 Knapsack, unbounded Knapsack, longest common substring, and palindromic subsequence. That covers most interview DP questions.

    Pattern 15: Topological Sort

    What it is: Linear ordering of vertices in a directed acyclic graph (DAG) such that for every edge u→v, u comes before v. Uses BFS (Kahn's algorithm) or DFS.

    When to use it: Task scheduling, dependency resolution, course prerequisites, build order problems.

    Example problem: Course Schedule, Course Schedule II, Alien Dictionary.

    The Study Order That Actually Works

    Don't try to learn all 15 at once. Here's the order I'd recommend over a 4-6 week period:

    1. Week 1: Two Pointers, Sliding Window, Modified Binary Search — these are the most intuitive and build confidence fast.
    2. Week 2: BFS, DFS — you'll use these everywhere, and they unlock a huge chunk of problems.
    3. Week 3: Fast & Slow Pointers, In-Place Linked List Reversal, Cyclic Sort — linked list and array manipulation patterns.
    4. Week 4: Merge Intervals, Subsets & Permutations — interval and backtracking problems.
    5. Week 5: Top K Elements, K-Way Merge, Two Heaps — heap-based patterns.
    6. Week 6: Dynamic Programming, Topological Sort — the hardest patterns, saved for when your problem-solving muscle is warmed up.

    Do 2-3 problems per pattern. That's about 40 problems total. Way less than 500 random grinds, and way more effective.

    One Last Thing

    Recognizing patterns is half the battle — the other half is explaining your approach clearly while you code. Interviewers care as much about your thought process as your solution. If you want real-time help talking through problems during interviews, grab Craqly — it listens to your interview and gives you pattern hints and approach suggestions without anyone knowing.

    Share this article
    C

    Written by

    Craqly Team

    Comments

    Leave a comment

    No comments yet. Be the first to share your thoughts!

    Ready to Transform Your Interview Skills?

    Join thousands of professionals who have improved their interview performance with AI-powered practice sessions.