This post is heavily borrowed from this Linkedin Post

Passing leetcode hackerrank DSA interviews mostly involves matching patterns to problems and applying the appropriate algorithm.

We mostly use these 15 essential DSA patterns :

  1. Sliding Window :
  • Keywords: subarray, window, consecutive, fixed size, substring, contiguous
  1. Two Pointers :
  • Keywords: sorted, left/right, opposite ends, pair sum, move pointers, partition
  1. Prefix Sum :
  • Keywords: cumulative, sum, range sum, running total, precompute, difference
  1. Tree Traversal :
  • Keywords: binary tree, root, left/right, preorder, inorder, postorder
  1. DFS :
  • Keywords: recursion, stack, path, explore, graph, tree, visited, unvisited
  1. BFS :
  • Keywords: queue, shortest path, level, neighbors, layers, graph, tree
  1. Matrix Traversal :
  • Keywords: grid, 2D array, up, down, left, right, diagonal, neighbors, rows, columns
  1. Backtracking :
  • Keywords: all solutions, permutation, combination, path, recursive, choices, undo
  1. Dynamic Programming :
  • Keywords: minimum, maximum, optimal, memoizatoin, table, recurrence, state
  1. Fast & Slow Pointers :
  • Keywords: cycle, mid point, loop, linked list, fast, slow, tortoise, hare, detect
  1. In Place Reversal :
  • Keywords: reverse, swap, rotate, in place, modify list array, two pointers
  1. Monotonic Stack :
  • Keywords: stack, increasing, decreasing, span, next greater, next smaller, break in continuity trend
  1. Binary Search :
  • Keywords: sorted, search, peak, low, high, find, condition, target in sorted array
  1. Heap / Top K / Priority Queue :
  • Keywords: K largest, K smallest, heap, priority queue, min, max, frequent, selection, scheduling
  1. Overlapping Intervals :
  • Keywords: intervals, merge, overlap, schedule, sort by start or end, meeting, balloon burst