AAPICODE.IO
Algorithms & InterviewsIntermediate 8 min readUpdated 2026-04

Top Algorithm Patterns for Interviews

A categorized index of the patterns that explain most LeetCode-style problems — sliding window, two pointers, DP, DFS/BFS, hashing, greedy, and beyond.

AlgorithmsInterviewsPatterns

Foundational patterns

  • Sliding Window — Maximum Subarray, Longest Substring Without Repeating Characters.
  • Two Pointers — Two Sum, Reverse Linked List, Remove Duplicates.
  • Hashing — Two Sum, Contains Duplicate, Group Anagrams.
  • Greedy — Jump Game, Coin Change, Best Time to Buy/Sell Stock.
  • Binary Search — Search Insert Position, Find First/Last Position, Find Peak Element.

Tree, graph, and search

  • DFS — Inorder Traversal, Validate BST.
  • BFS — Level Order Traversal, Rotting Oranges, Min Depth.
  • Graph — Clone Graph, Course Schedule, Number of Islands.
  • Trie — Implement Trie, Word Search II, Add and Search Word.
  • Topological Sort — Course Schedule, Alien Dictionary.

Dynamic programming family

  • Classic DP — Fibonacci, Longest Common Subsequence, Min Path Sum.
  • Knapsack — 0/1, Unbounded, Fractional.
  • DP + Bitmask — Partition / Subset Sum.
  • Memoized recursion — turn brute force into polynomial.

Data-structure-specific

  • Stack — Daily Temperatures, RPN.
  • Queue — Sliding Window Maximum, Circular Queue.
  • Linked List — Reverse, Detect Cycle, Remove Duplicates.
  • Matrix — Spiral, Rotate Image, Search 2D Matrix.
  • Segment Tree / BIT — Range Sum, Range Min, Range Update.