15
Core patterns covering ~85% of all coding questions
150–200
Target problems for complete coding interview prep
30 sec
Target time to identify pattern from problem statement
3–4 mo
Time to master all 15 patterns with daily practice

The biggest mistake engineers make in DSA prep is grinding problems in random order. Pattern-first learning is 3–5x more efficient: you learn the underlying structure, then practice variations. When you see a new problem, pattern recognition happens in 30 seconds instead of 5 minutes of confusion.

How Indian Product Companies Use DSA Rounds At Flipkart, Razorpay, Meesho, Juspay, and similar companies, coding rounds typically have 2 problems in 90 minutes. Problems are medium-difficulty with occasional hard. The emphasis is on: (1) arriving at the right approach quickly, (2) clean, readable code, (3) correct time/space complexity analysis, and (4) handling edge cases verbally before coding.
1
Sliding Window Very High Frequency
Recognition Signal: Problem involves a contiguous subarray/substring. Keywords: "maximum/minimum of k elements", "longest substring with condition", "subarray sum equals k".

When to use: Finding max/min of a subarray of fixed or variable size. Reduces O(n²) brute force to O(n).

Types: Fixed window (size k given) vs. Variable window (expand/contract based on condition).

  • Max Sum Subarray of Size K
  • Longest Substring Without Repeating Chars
  • Minimum Window Substring
  • Fruit Into Baskets
2
Two Pointers Very High Frequency
Recognition Signal: Sorted array or string. Looking for pairs/triplets summing to target. Comparing elements from both ends. Palindrome check.

When to use: Eliminates nested loops on sorted arrays. Reduces O(n²) to O(n).

  • Two Sum II (sorted input)
  • 3Sum
  • Container With Most Water
  • Valid Palindrome II
  • Remove Duplicates from Sorted Array
3
Fast & Slow Pointers Medium Frequency
Recognition Signal: Linked list cycle detection. Finding middle of linked list. Detecting loops in any sequence.

When to use: Cycle detection in O(1) space. Finding intersection of linked lists. Identifying kth from end.

  • Linked List Cycle
  • Linked List Cycle II (start of cycle)
  • Middle of Linked List
  • Happy Number
4
Merge Intervals High Frequency
Recognition Signal: Problem gives a list of intervals. Asks to merge overlapping, find free slots, insert interval, or check for conflicts. Scheduling problems.

When to use: Sorting by start time first, then iterating with merge logic.

  • Merge Intervals
  • Insert Interval
  • Non-overlapping Intervals
  • Meeting Rooms II
5
Cyclic Sort Medium Frequency
Recognition Signal: Array contains numbers in range [1, n] or [0, n-1]. Problem asks to find missing or duplicate numbers without extra space.

When to use: Place each number at its correct index by swapping. Then scan for mismatches.

  • Find Missing Number
  • Find All Duplicates in Array
  • Set Mismatch
  • First Missing Positive
6
BFS on Trees/Graphs Very High Frequency
Recognition Signal: Level-order traversal. Shortest path in unweighted graph. "Minimum steps" problems. Rotting oranges type problems.

When to use: Any problem requiring processing by levels or finding shortest path. Use a queue (deque in Python).

  • Binary Tree Level Order Traversal
  • Rotting Oranges
  • Word Ladder
  • 0/1 Matrix
  • Shortest Path in Binary Matrix
7
DFS / Backtracking Very High Frequency
Recognition Signal: Find ALL solutions/combinations/permutations. "Generate all..." problems. Maze/path problems. Constraint satisfaction.

When to use: Explore all possibilities; undo ("backtrack") when a path doesn't work. The core pattern: choose, explore, unchoose.

  • Subsets
  • Permutations
  • Combination Sum
  • N-Queens
  • Word Search
  • Palindrome Partitioning
8
Binary Search (Classic + On Answer) High Frequency
Recognition Signal: Sorted array (classic). "Minimize the maximum" or "maximize the minimum" (binary search on answer). Rotated sorted array. Search space can be ordered.

When to use: Classic: sorted array, O(log n) search. On Answer: the answer lies in a range; binary search for valid answer instead of elements.

  • Search in Rotated Sorted Array
  • Find Minimum in Rotated Array
  • Koko Eating Bananas
  • Capacity to Ship Packages
  • Median of Two Sorted Arrays
9
Top K Elements (Heap) High Frequency
Recognition Signal: "Top K", "K largest", "K most frequent", "K closest". Finding Kth element. Streaming data problems.

When to use: Min-heap of size K for "Top K largest". Max-heap for "Top K smallest". Don't sort the whole array when you only need K elements.

  • Kth Largest Element in Array
  • Top K Frequent Elements
  • K Closest Points to Origin
  • Find K Pairs with Smallest Sums
10
Dynamic Programming — 1D Very High Frequency
Recognition Signal: Optimal substructure: the solution to the problem depends on solutions to smaller versions of the same problem. "Max/min ways", "count paths", "can we achieve X?"

Key 1D patterns: Fibonacci-style (dp[i] = dp[i-1] + dp[i-2]), Kadane's algorithm (max subarray), coin change, climbing stairs.

  • Climbing Stairs
  • House Robber
  • Coin Change
  • Maximum Subarray (Kadane's)
  • Longest Increasing Subsequence
  • Word Break
11
Dynamic Programming — 2D/Grid High Frequency
Recognition Signal: Grid path problems. Two-string comparison (edit distance, LCS, LPS). Knapsack-style problems.

Key 2D patterns: Grid DP (dp[i][j] depends on dp[i-1][j] and dp[i][j-1]). String DP (dp[i][j] represents answer for first i chars of s1 and j chars of s2).

  • Unique Paths
  • Minimum Path Sum
  • Longest Common Subsequence
  • Edit Distance
  • 0/1 Knapsack
12
Graph Algorithms (Shortest Path, Union-Find) High Frequency
Recognition Signal: Weighted graph shortest path → Dijkstra. Number of connected components → Union-Find or DFS. Cycle detection in directed graph → DFS with color states.
  • Number of Islands
  • Number of Connected Components
  • Course Schedule (Cycle Detection)
  • Network Delay Time (Dijkstra)
  • Redundant Connection (Union-Find)
13
Monotonic Stack Medium-High Frequency
Recognition Signal: "Next greater element", "previous smaller element", "largest rectangle", "daily temperatures". Need to find the next/previous element satisfying a condition for each element.

When to use: Maintain a stack of elements in monotonically increasing or decreasing order. Pop when the current element violates the order.

  • Daily Temperatures
  • Next Greater Element I & II
  • Largest Rectangle in Histogram
  • Trapping Rain Water
14
Trie (Prefix Tree) Medium Frequency
Recognition Signal: Word search, prefix matching, autocomplete. "Does any word in the dictionary...?" with multiple lookups. XOR maximization (bit trie).

When to use: Efficient prefix operations on strings. Each node represents a character; the path from root to node spells a prefix.

  • Implement Trie
  • Word Search II
  • Design Add and Search Words
  • Maximum XOR of Two Numbers (Bit Trie)
15
Bit Manipulation Medium Frequency
Recognition Signal: "Without extra space", "in O(1) space". Single number in array of duplicates. Power of 2. Counting bits. XOR patterns.

Key operations: XOR self-cancels (a^a=0). AND with n-1 removes lowest set bit. Shift operators for multiplication/division by 2. Bit masking for subsets.

  • Single Number
  • Number of 1 Bits
  • Reverse Bits
  • Power of Two
  • Sum of Two Integers (no + operator)

Pattern Recognition Quick Reference

If You See This...Think This Pattern
Contiguous subarray, max/min conditionSliding Window
Sorted array, pairs/triplets summing to targetTwo Pointers
Linked list cycle, find middleFast & Slow Pointers
Overlapping intervals, schedulingMerge Intervals
Array [1..n], find missing/duplicateCyclic Sort
Level-order, shortest path in unweighted graphBFS
All combinations/permutations, "generate all"DFS / Backtracking
Sorted search space, "minimize maximum"Binary Search
Top K, K largest/smallest/frequentHeap
Optimal substructure, count/min/max waysDynamic Programming
Connected components, cycle detectionGraph (DFS/BFS/Union-Find)
Next greater/smaller elementMonotonic Stack
Prefix matching, autocomplete, word searchTrie
O(1) space, XOR, duplicates, power of 2Bit Manipulation
The 3-Step Pattern Attack in Interviews (1) Read the problem twice. Identify keywords. Map to a pattern from the table above. (2) Verbalize: "This looks like a sliding window problem because..." — thinking aloud shows your process even if you're not sure. (3) Code the pattern skeleton first, then fill in problem-specific logic. Most interviewers give partial credit for recognizing the approach even if implementation has minor bugs.

Study Plan: Master All 15 Patterns in 12 Weeks

WeekPatternsProblem Target
Week 1–2Sliding Window + Two Pointers25–30 problems
Week 3Fast & Slow + Merge Intervals15 problems
Week 4BFS + DFS/Backtracking (basics)20 problems
Week 5–6Binary Search + Heap20 problems
Week 7–81D DP + 2D DP25 problems
Week 9–10Graph Algorithms + Advanced DFS/Backtracking20 problems
Week 11Monotonic Stack + Trie15 problems
Week 12Cyclic Sort + Bit Manipulation + Mock Interviews15 problems + 4 mocks