Blog

Reference

The 15 DSA Patterns That Cover 90% of Coding Interviews

8 min read

Topic frequency tells you what to study. Patterns tell you how to solve it once the question is in front of you. These are different skills, and the second one is what actually wins interviews. A strong candidate doesn't recall the answer to a problem — they recognise its shape in the first 60 seconds and reach for the matching template.

The good news: there are only about fifteen of these shapes. Master the recognition trigger for each, and the overwhelming majority of interview questions become "oh, that's a sliding window with a twist" instead of a blank-page panic. Here's the catalogue.

The recognition table

Read this column-by-column. When you see the signal on the left in a problem statement, the pattern on the right is your first guess — right far more often than chance.

If you see this signalReach for
Sorted array, find a pair/triplet summing to a targetTwo pointers
Longest/shortest contiguous subarray or substringSliding window
Range-sum queries, "subarray with sum K"Prefix sums
Cycle detection, find the middle, k-th from end (linked list)Fast & slow pointers
Overlapping or back-to-back intervals to merge/scheduleMerge intervals
"Find the smallest/largest value such that…" on a monotonic answerBinary search on answer
Top-K, k-th largest, streaming medianHeap / priority queue
All permutations / combinations / subsets / valid configurationsBacktracking
Grid/maze, connected components, shortest path in unweighted graphBFS / DFS on graph
Dependencies, ordering, prerequisitesTopological sort
Next greater/smaller element, spans, histogramsMonotonic stack
"Min/max number of ways", overlapping subproblems & choicesDynamic programming
Locally optimal choice obviously leads to global bestGreedy
Prefix/word lookups, autocompleteTrie
Grouping elements, "are these connected", merging setsUnion-Find (DSU)

The four you'll use most

Five patterns carry the bulk of array/string interviews. Get fluent in these before anything else.

Two pointers

Trigger: a sorted array and a relationship between two elements. The classic tell is "find a pair/triplet that sums to X". Representative problems from the curated set: Two Sum II (sorted input), 3Sum, Container With Most Water, removing duplicates from a sorted array.

Sliding window

Trigger: the word contiguous plus "longest", "shortest", or "at most K". You grow a window from the right and shrink from the left to maintain a constraint. Representative: longest substring without repeating characters, minimum window substring, max sum subarray of size K, fruit-into-baskets.

Fast & slow pointers

Trigger: a linked list (or implicit cycle) where you need the middle, a loop, or the k-th node from the end without knowing the length. Representative: linked list cycle detection, middle of a linked list, happy number, palindrome linked list.

Dynamic programming

Trigger: overlapping subproblems and a sequence of choices where each choice affects what's available next ("take it or skip it"). If brute-force recursion recomputes the same state, that's your DP signal. Representative: climbing stairs, house robber, coin change, longest common subsequence, 0/1 knapsack. DP is the pattern people fear most — but it's just recursion plus a memo table, learned by repetition.

The study loop: pick one, solve eight, move on

Do not solve random problems. Patterns are learned by concentration, not variety. The loop that works:

  1. Pick one pattern. Read its recognition trigger above until you can state it from memory.
  2. Solve one easy example with the solution open. You're learning the template, not testing yourself yet.
  3. Solve 6–8 more of the same pattern, increasing difficulty. By problem four you should spot the shape before reading the constraints.
  4. Write the trigger and template in one line in your own notes. "Sorted + pair sum → two pointers from both ends."
  5. Move on. Don't perfect a pattern — eight reps is enough to recognise it. Come back during revision.

Fifteen patterns at eight problems each is about 120 focused problems — a few weeks of honest work, not months. That's the whole game.

Practise them in role-relevant order

Not every pattern is worth the same to every candidate. A frontend loop leans on two pointers, sliding window, and hashing; a backend loop pulls graphs, topological sort, and heaps up front. So sequence your fifteen patterns by the role you're targeting rather than alphabetically. That ordering is exactly what SUITS does — it reorders the curated Apna College, Love Babbar 450, and Striver A2Z problems so the patterns your target role tests most appear first.

For which patterns matter most by role, see the DSA roadmap by role. To fit this pattern work into a deadline, drop it into the 90-day placement plan.

Keep reading

Guide

DSA for the Amazon SDE Interview — A Deep, Specific Guide

Amazon is the most predictable big-tech loop a fresher can prepare for — but only if you know its actual lean: grids and graphs over exotic DP, a debugging section in the OA, and Leadership Principles that quietly decide SDE-1 offers. Here's the deep, Amazon-only plan.

7 min read
Strategy

Company-Specific DSA Without LeetCode Premium (Free Alternatives)

LeetCode Premium's company tags cost roughly $35/month — and the moment you have an interview date, that paywall feels mandatory. It isn't. Here's how to reconstruct most of that signal for free, and the one thing Premium genuinely does better.

7 min read
The 15 DSA Patterns That Cover 90% of Coding Interviews | DSA Tracker