issue 117apr 27mmxxvi
est. 2017
Sun, 27 Apr 2026
vol. IX · no. 117
PapersAdda
placement intelligence, since 2017
868 briefs · 24 campuses · by reservation
verified offers · sourced from r/developersIndia
razorpay₹65.00 LPA· iit-d · sde-1google₹54.00 LPA· iiit-h · swe-imicrosoft₹49.50 LPA· iit-b · sdeatlassian₹38.00 LPA· nit-w · sde-1amazon₹44.20 LPA· bits-p · sde-1uber₹42.00 LPA· iit-kgp · sde-1razorpay₹65.00 LPA· iit-d · sde-1google₹54.00 LPA· iiit-h · swe-imicrosoft₹49.50 LPA· iit-b · sdeatlassian₹38.00 LPA· nit-w · sde-1amazon₹44.20 LPA· bits-p · sde-1uber₹42.00 LPA· iit-kgp · sde-1

14 Coding Patterns That Solve 90% of FAANG Interviews [2026 Guide]

8 min read
Topics & Practice
Last Updated: 1 May 2026
Reviewed by PapersAdda Editorial

If you have been grinding LeetCode and feel like every problem looks new, you are missing the meta-skill: most coding interview problems are variants of 14 patterns. Learn these 14 templates well and you reduce a 600-problem grind to a 60-problem grind, three to four representative problems per pattern.

This is not theory; it is the exact blueprint product companies' interviewers themselves use to pick problems. They open a pattern bucket, pick a question, and tweak it. Your job is to recognise which bucket they reached into.

Background: review the DSA sheet for placements 2026 for the foundational data-structure refresher.


How to Use This Guide

  1. Read the pattern's signature, what does the problem look like when this pattern applies?
  2. Memorise the template, there is one canonical loop or recursion shape per pattern.
  3. Solve the 3 sample problems listed for each pattern, then 5–10 variants from LeetCode tagged with the same pattern.
  4. Re-read this list every Sunday for 6 weeks. By week 4 you will be classifying problems faster than you can solve them.

Pattern 1, Sliding Window

Signature: asked to find a subarray, substring, or window with a property, longest, shortest, sum equals K, contains K distinct, etc.

Template:

def sliding_window(arr, k):
    left = 0
    state = init_state()
    result = init_result()
    for right in range(len(arr)):
        update(state, arr[right])
        while not valid(state):
            shrink(state, arr[left])
            left += 1
        result = update_result(result, right - left + 1)
    return result

Sample problems:

  1. Longest substring without repeating characters
  2. Maximum sum subarray of size K
  3. Smallest subarray with sum ≥ S

Pattern 2, Two Pointers

Signature: sorted array, asked to find pairs, triplets, or partition by some condition.

Template:

def two_pointers(arr, target):
    left, right = 0, len(arr) - 1
    while left < right:
        s = arr[left] + arr[right]
        if s == target:
            return [left, right]
        elif s < target:
            left += 1
        else:
            right -= 1

Sample problems:

  1. Pair with sum K in sorted array
  2. Three-sum (find triplets summing to 0)
  3. Container with most water

Pattern 3, Fast and Slow Pointers (Floyd's)

Signature: linked list cycle, finding the middle, or detecting if a sequence eventually repeats.

Template:

def has_cycle(head):
    slow = fast = head
    while fast and fast.next:
        slow = slow.next
        fast = fast.next.next
        if slow == fast:
            return True
    return False

Sample problems:

  1. Detect cycle in linked list
  2. Find the start of the cycle
  3. Happy number (does the sum-of-squared-digits loop hit 1?)

Pattern 4, Merge Intervals

Signature: intervals are given; you need to merge, schedule, find overlap, or count free time.

Template:

def merge_intervals(intervals):
    intervals.sort(key=lambda x: x[0])
    merged = [intervals[0]]
    for current in intervals[1:]:
        if current[0] <= merged[-1][1]:
            merged[-1][1] = max(merged[-1][1], current[1])
        else:
            merged.append(current)
    return merged

Sample problems:

  1. Merge overlapping intervals
  2. Insert a new interval into a sorted list
  3. Meeting rooms II (minimum rooms required)

Pattern 5, Cyclic Sort

Signature: array contains numbers in a known range like 1 to N, find the missing, the duplicate, or the smallest missing positive.

Template:

def cyclic_sort(nums):
    i = 0
    while i < len(nums):
        j = nums[i] - 1
        if 0 <= j < len(nums) and nums[i] != nums[j]:
            nums[i], nums[j] = nums[j], nums[i]
        else:
            i += 1
    return nums

Sample problems:

  1. Find the missing number from 0 to N
  2. Find all duplicates in an array
  3. Find first K missing positives

Pattern 6, In-place Linked List Reversal

Signature: reverse a list, or reverse parts of a list (every K nodes, alternate K).

Template:

def reverse_list(head):
    prev = None
    curr = head
    while curr:
        nxt = curr.next
        curr.next = prev
        prev = curr
        curr = nxt
    return prev

Sample problems:

  1. Reverse a linked list
  2. Reverse every K nodes
  3. Reverse alternating K nodes

Pattern 7, Tree BFS

Signature: any tree-traversal problem where you need level-by-level processing, level order, zigzag, right view.

Template:

from collections import deque
def tree_bfs(root):
    if not root: return []
    result = []
    queue = deque([root])
    while queue:
        size = len(queue)
        level = []
        for _ in range(size):
            node = queue.popleft()
            level.append(node.val)
            if node.left: queue.append(node.left)
            if node.right: queue.append(node.right)
        result.append(level)
    return result

Sample problems:

  1. Level order traversal
  2. Zigzag level order
  3. Right side view of a binary tree

Pattern 8, Tree DFS

Signature: path-related, root-to-leaf, sum equals target, all paths, max depth, diameter.

Template:

def dfs(node, target, path, result):
    if not node: return
    path.append(node.val)
    if not node.left and not node.right and sum(path) == target:
        result.append(list(path))
    dfs(node.left, target, path, result)
    dfs(node.right, target, path, result)
    path.pop()

Sample problems:

  1. All root-to-leaf paths
  2. Path sum equals K
  3. Diameter of binary tree

Pattern 9, Two Heaps

Signature: find the median in a stream, or split data into two halves where one half holds the larger and one holds the smaller.

Template: maintain a max-heap of the lower half and a min-heap of the upper half, balanced so their sizes differ by at most 1.

Sample problems:

  1. Find median from a data stream
  2. Sliding window median
  3. Maximize capital with K projects

Pattern 10, Subsets / Backtracking

Signature: generate all combinations, permutations, partitions, or solve N-queens / Sudoku / word break.

Template:

def subsets(nums):
    result = []
    def backtrack(start, path):
        result.append(list(path))
        for i in range(start, len(nums)):
            path.append(nums[i])
            backtrack(i + 1, path)
            path.pop()
    backtrack(0, [])
    return result

Sample problems:

  1. All subsets of a list
  2. All permutations
  3. Partition string into palindromes

Signature: sorted array but rotated, or asked to find boundary, or asked to search in infinite array.

Template:

def search_rotated(nums, target):
    left, right = 0, len(nums) - 1
    while left <= right:
        mid = (left + right) // 2
        if nums[mid] == target: return mid
        if nums[left] <= nums[mid]:
            if nums[left] <= target < nums[mid]:
                right = mid - 1
            else:
                left = mid + 1
        else:
            if nums[mid] < target <= nums[right]:
                left = mid + 1
            else:
                right = mid - 1
    return -1

Sample problems:

  1. Search in rotated sorted array
  2. Find first / last position of target
  3. Find peak element

Pattern 12, Top K Elements

Signature: find the K largest, K smallest, K most frequent, or K closest.

Template:

import heapq
def top_k_frequent(nums, k):
    freq = {}
    for n in nums:
        freq[n] = freq.get(n, 0) + 1
    return [n for n, _ in heapq.nlargest(k, freq.items(), key=lambda x: x[1])]

Sample problems:

  1. K largest elements
  2. K most frequent words
  3. K closest points to origin

Pattern 13, K-way Merge

Signature: K sorted lists or arrays, merge them, find the smallest range, or find the kth element across all.

Template: push the head of each list into a min-heap; pop the smallest, push the next from that list.

Sample problems:

  1. Merge K sorted linked lists
  2. Smallest range covering elements from K lists
  3. Find Kth smallest element in M sorted lists

Pattern 14, 0/1 Knapsack and Topological Sort

0/1 Knapsack signature: maximise / minimise some value with a constraint, often with item-pick or item-skip choice.

Template:

def knapsack(weights, values, capacity):
    n = len(weights)
    dp = [[0] * (capacity + 1) for _ in range(n + 1)]
    for i in range(1, n + 1):
        for w in range(capacity + 1):
            if weights[i-1] <= w:
                dp[i][w] = max(dp[i-1][w], dp[i-1][w - weights[i-1]] + values[i-1])
            else:
                dp[i][w] = dp[i-1][w]
    return dp[n][capacity]

Topological Sort signature: dependencies between tasks, schedule courses, build order, alien dictionary.

Sample problems (knapsack):

  1. Equal subset sum partition
  2. Coin change (min coins)
  3. Longest common subsequence

Sample problems (topo sort):

  1. Course schedule (can finish?)
  2. Course schedule II (return order)
  3. Alien dictionary

Drilling Plan: 6 Weeks to Proficiency

WeekPatternsGoal
1Sliding Window, Two Pointers, Fast & SlowSolve 4 problems per pattern
2Merge Intervals, Cyclic Sort, ReversalSolve 4 problems per pattern
3Tree BFS, Tree DFSSolve 6 problems per pattern
4Two Heaps, Subsets, Modified Binary SearchSolve 4 problems per pattern
5Top K, K-way Merge, KnapsackSolve 4 problems per pattern
6Topological Sort + mixed mockOne problem from each pattern, 25-min timer

By the end of week 6, you should be able to classify the pattern of any new problem within 60 seconds and start writing the template within 90 seconds. That is the unlock, the rest is execution speed.

For company-specific drills, see Infosys SP/DSE coding questions, TCS NQT mock test, and the system design basics for freshers once you finish DSA.

Explore this topic cluster

More resources in Topics & Practice

Use the category hub to browse similar questions, exam patterns, salary guides, and preparation resources related to this topic.

Paid contributor programme

Sat this this year? Share your story, earn ₹500.

First-person experience reports help future candidates prep smarter. We pay verified contributors ₹500 via UPI per accepted story — with byline.

Submit your story →

Ready to practice?

Take a free timed mock test

Put what you learned into practice. Our mock tests match the 2026 pattern with timer, navigator, reveal, and score breakdown. No signup.

Start Free Mock Test →

More from PapersAdda

Share this guide: