Skip to content

Patterns to master

Girish Prabhu edited this page Sep 18, 2020 · 7 revisions

Here are a few patterns to master

  • Sliding Window
  • Binary Search Patterns
  • Using Min/Max Heap
  • Graph Traversals (DFS, BFS, Topological Sort, Dijkstra's)
    • Min Distance (with/without k hops) (BFS)
    • Min Cost (Dijkstras)
    • Reachability (DFS)
    • Ordering (Topological Sort)
  • BST and Binary Tree (Inorder, Pre/Post, BFS/DFS, height/diameter, Balanced)
  • Arrays (prefix sums, left/right pointers)
  • Strings (palindromes, BFS/DFS, pattern matching - Rolling Hash/KMP)
  • Trie
  • Union Find
  • Dynamic Programming
    • Kadane's Algorithm
    • Monotonic queues
  • Quick select (Alternative to heap sort for kth element)
  • Fenwick Tree
  • Segment Tree and Interval Tree

Clone this wiki locally