Pattern Almanac

Master 144 algorithm patterns to ace your coding interviews

144 patterns

1D DP

Dynamic Programming
1 Easy
0 Medium
0 Hard
1 problems

2D DP

Dynamic Programming
0 Easy
2 Medium
0 Hard
2 problems

Array / Design

Design
0 Easy
1 Medium
0 Hard
1 problems

Backtracking

Backtracking
0 Easy
2 Medium
0 Hard
2 problems

Backtracking (Permutations)

Backtracking
0 Easy
1 Medium
0 Hard
1 problems

Backtracking / Skip Duplicates

Backtracking
0 Easy
1 Medium
0 Hard
1 problems

Backtracking / Stack

Stack
0 Easy
1 Medium
0 Hard
1 problems

Backtracking on Grid

Backtracking
0 Easy
1 Medium
0 Hard
1 problems

Backtracking with Constraints

Backtracking
0 Easy
0 Medium
1 Hard
1 problems

Backtracking with Duplicate Handling

Backtracking
0 Easy
1 Medium
0 Hard
1 problems

Backtracking with Reuse

Backtracking
0 Easy
1 Medium
0 Hard
1 problems

Backtracking with Skip Duplicates

Backtracking
0 Easy
1 Medium
0 Hard
1 problems

Backtracking with Validation

Backtracking
0 Easy
1 Medium
0 Hard
1 problems

BFS

Graphs
0 Easy
0 Medium
1 Hard
1 problems

BFS / Queue

Trees
0 Easy
1 Medium
0 Hard
1 problems

BFS or Bellman-Ford

Advanced Graphs
0 Easy
1 Medium
0 Hard
1 problems

BFS or DFS with Level Tracking

Trees
0 Easy
1 Medium
0 Hard
1 problems

Binary Exponentiation

Math & Geometry
0 Easy
1 Medium
0 Hard
1 problems

Binary Search

Binary Search
2 Easy
1 Medium
1 Hard
4 problems

Binary Search (Modified)

Binary Search
0 Easy
2 Medium
0 Hard
2 problems

Binary Search / Matrix

Binary Search
0 Easy
1 Medium
0 Hard
1 problems

Binary Search / Modified

Binary Search
0 Easy
1 Medium
0 Hard
1 problems

Binary Search + BFS or Dijkstra

Advanced Graphs
0 Easy
0 Medium
1 Hard
1 problems

Binary Search on Answer

Binary Search
0 Easy
1 Medium
0 Hard
1 problems

Binary Search with HashMap

Binary Search
0 Easy
1 Medium
0 Hard
1 problems

Bit Manipulation

Bit Manipulation
2 Easy
2 Medium
0 Hard
4 problems

Bit Manipulation (XOR)

Bit Manipulation
1 Easy
0 Medium
0 Hard
1 problems

Boyer-Moore Voting / Hash Map

Arrays
1 Easy
0 Medium
0 Hard
1 problems

BST Properties

Trees
0 Easy
2 Medium
0 Hard
2 problems

DFS / BFS

Graphs
1 Easy
2 Medium
0 Hard
3 problems

DFS / Combinatorics

Trees
0 Easy
0 Medium
1 Hard
1 problems

DFS with Memoization

2-D Dynamic Programming
0 Easy
0 Medium
1 Hard
1 problems

DFS/BFS (Reverse)

Graphs
0 Easy
1 Medium
0 Hard
1 problems

DFS/BFS + Cycle Detection

Graphs
0 Easy
1 Medium
0 Hard
1 problems

DFS/BFS from Border

Graphs
0 Easy
1 Medium
0 Hard
1 problems

DFS/BFS or Union Find

Graphs
0 Easy
1 Medium
0 Hard
1 problems

DFS/BFS with Hash Map

Graphs
0 Easy
1 Medium
0 Hard
1 problems

Dijkstra's Algorithm

Advanced Graphs
0 Easy
1 Medium
0 Hard
1 problems

Divide and Conquer / BST

Trees
1 Easy
0 Medium
0 Hard
1 problems

DP / LIS

Dynamic Programming
0 Easy
0 Medium
1 Hard
1 problems

Dynamic Programming (0/1 Knapsack)

1-D Dynamic Programming
0 Easy
1 Medium
0 Hard
1 problems

Dynamic Programming (1D)

1-D Dynamic Programming
2 Easy
3 Medium
0 Hard
5 problems

Dynamic Programming (1D) with Cases

1-D Dynamic Programming
0 Easy
1 Medium
0 Hard
1 problems

Dynamic Programming (2D)

2-D Dynamic Programming
0 Easy
3 Medium
3 Hard
6 problems

Dynamic Programming (Interval DP)

2-D Dynamic Programming
0 Easy
0 Medium
1 Hard
1 problems

Dynamic Programming (LIS)

1-D Dynamic Programming
0 Easy
1 Medium
0 Hard
1 problems

Dynamic Programming (State Machine)

2-D Dynamic Programming
0 Easy
1 Medium
0 Hard
1 problems

Dynamic Programming (Subset Sum)

2-D Dynamic Programming
0 Easy
1 Medium
0 Hard
1 problems

Dynamic Programming (Track Min/Max)

1-D Dynamic Programming
0 Easy
1 Medium
0 Hard
1 problems

Dynamic Programming (Unbounded Knapsack)

1-D Dynamic Programming
0 Easy
2 Medium
0 Hard
2 problems

Dynamic Programming + Bit Manipulation

Bit Manipulation
1 Easy
0 Medium
0 Hard
1 problems

Eulerian Path (Hierholzer's)

Advanced Graphs
0 Easy
0 Medium
1 Hard
1 problems

Expand Around Center

1-D Dynamic Programming
0 Easy
2 Medium
0 Hard
2 problems

Fast & Slow Pointers (Floyd's)

Linked List
1 Easy
0 Medium
0 Hard
1 problems

Floyd's Cycle Detection

Linked List
0 Easy
1 Medium
0 Hard
1 problems

Greedy

Greedy
0 Easy
4 Medium
0 Hard
4 problems

Greedy (BFS-like)

Greedy
0 Easy
1 Medium
0 Hard
1 problems

Greedy / DP

Dynamic Programming
0 Easy
1 Medium
0 Hard
1 problems

Greedy / Intervals

Intervals
0 Easy
1 Medium
0 Hard
1 problems

Greedy with Hash Map

Greedy
0 Easy
1 Medium
0 Hard
1 problems

Greedy with Range

Greedy
0 Easy
1 Medium
0 Hard
1 problems

Hash Map

Arrays & Hashing
2 Easy
1 Medium
0 Hard
3 problems

Hash Map / Design

Design
0 Easy
1 Medium
0 Hard
1 problems

Hash Map / Frequency Counter

Arrays & Hashing
3 Easy
0 Medium
0 Hard
3 problems

Hash Map / Two Pointers

Arrays
0 Easy
1 Medium
0 Hard
1 problems

Hash Map + Doubly Linked List

Linked List
0 Easy
1 Medium
0 Hard
1 problems

Hash Map + Heap (K-way merge)

Heap / Priority Queue
0 Easy
1 Medium
0 Hard
1 problems

Hash Map or Interweaving

Linked List
0 Easy
1 Medium
0 Hard
1 problems

Hash Map with Sorted Key

Arrays & Hashing
0 Easy
1 Medium
0 Hard
1 problems

Hash Set

Arrays & Hashing
1 Easy
1 Medium
0 Hard
2 problems

Hash Set (multiple)

Arrays & Hashing
0 Easy
1 Medium
0 Hard
1 problems

Hash Set or Fast/Slow Pointers

Math & Geometry
1 Easy
0 Medium
0 Hard
1 problems

Heap / Bucket Sort

Arrays & Hashing
0 Easy
1 Medium
0 Hard
1 problems

Heap / Priority Queue

Linked List
0 Easy
0 Medium
1 Hard
1 problems

Heap / Sweep Line

Intervals
0 Easy
1 Medium
0 Hard
1 problems

Heap with Cooldown Queue

Heap / Priority Queue
0 Easy
1 Medium
0 Hard
1 problems

In-order Traversal

Trees
0 Easy
1 Medium
0 Hard
1 problems

Intervals

Intervals
0 Easy
1 Medium
0 Hard
1 problems

Intervals / Sorting

Intervals
1 Easy
1 Medium
0 Hard
2 problems

Kadane's Algorithm

Greedy
0 Easy
1 Medium
0 Hard
1 problems

Linked List

Linked List
0 Easy
1 Medium
0 Hard
1 problems

Linked List / Two Pointers

Linked List
1 Easy
1 Medium
0 Hard
2 problems

Linked List Arithmetic

Linked List
0 Easy
1 Medium
0 Hard
1 problems

Linked List Reversal

Linked List
1 Easy
0 Medium
0 Hard
1 problems

Linked List Reversal in Groups

Linked List
0 Easy
0 Medium
1 Hard
1 problems

Math

Bit Manipulation
0 Easy
2 Medium
0 Hard
2 problems

Math / Probability

Math
0 Easy
1 Medium
0 Hard
1 problems

Math / Simulation

Math & Geometry
1 Easy
1 Medium
1 Hard
3 problems

Math / XOR / Hash Set

Arrays
1 Easy
0 Medium
0 Hard
1 problems

Math or XOR

Bit Manipulation
1 Easy
0 Medium
0 Hard
1 problems

Matrix Manipulation

Math & Geometry
0 Easy
2 Medium
0 Hard
2 problems

Matrix Traversal

Math & Geometry
0 Easy
1 Medium
0 Hard
1 problems

Max Heap

Heap / Priority Queue
1 Easy
0 Medium
0 Hard
1 problems

Min Heap of Size K

Heap / Priority Queue
1 Easy
0 Medium
0 Hard
1 problems

Min Heap or Quick Select

Heap / Priority Queue
0 Easy
1 Medium
0 Hard
1 problems

Monotonic Deque

Sliding Window
0 Easy
0 Medium
1 Hard
1 problems

Monotonic Stack

Stack
0 Easy
1 Medium
1 Hard
2 problems

Multi-source BFS

Graphs
0 Easy
2 Medium
0 Hard
2 problems

Multiple Steps (Find mid, Reverse, Merge)

Linked List
0 Easy
1 Medium
0 Hard
1 problems

Prefix/Suffix Product

Arrays & Hashing
0 Easy
1 Medium
0 Hard
1 problems

Prim's or Kruskal's MST

Advanced Graphs
0 Easy
1 Medium
0 Hard
1 problems

Quick Select or Min Heap

Heap / Priority Queue
0 Easy
1 Medium
0 Hard
1 problems

Shell Scripting

Shell
0 Easy
1 Medium
0 Hard
1 problems

Simulation

Simulation
1 Easy
0 Medium
0 Hard
1 problems

Sliding Window

Sliding Window
0 Easy
2 Medium
1 Hard
3 problems

Sliding Window / Greedy

Sliding Window
1 Easy
0 Medium
0 Hard
1 problems

Sliding Window with Frequency Match

Sliding Window
0 Easy
1 Medium
0 Hard
1 problems

Sorting + Heap

Intervals
0 Easy
0 Medium
1 Hard
1 problems

Stack

Stack
1 Easy
2 Medium
0 Hard
3 problems

Stack / Design

Stacks & Queues
1 Easy
0 Medium
0 Hard
1 problems

Stack / Linked List

Linked List
0 Easy
1 Medium
0 Hard
1 problems

Stack / Monotonic Stack

Stack
0 Easy
1 Medium
0 Hard
1 problems

Stack with Min Tracking

Stack
0 Easy
1 Medium
0 Hard
1 problems

String

Strings
1 Easy
0 Medium
0 Hard
1 problems

String / Simulation

Math
1 Easy
0 Medium
0 Hard
1 problems

String Manipulation / Delimiter

Arrays & Hashing
0 Easy
1 Medium
0 Hard
1 problems

Topological Sort

Graphs
0 Easy
1 Medium
1 Hard
2 problems

Topological Sort / Cycle Detection

Graphs
0 Easy
1 Medium
0 Hard
1 problems

Tree DFS

Trees
1 Easy
1 Medium
0 Hard
2 problems

Tree DFS (Nested)

Trees
1 Easy
0 Medium
0 Hard
1 problems

Tree DFS / BFS

Trees
1 Easy
0 Medium
0 Hard
1 problems

Tree DFS / In-order

Trees
0 Easy
1 Medium
0 Hard
1 problems

Tree DFS / Prefix Sum

Trees
0 Easy
1 Medium
0 Hard
1 problems

Tree DFS / Recursion

Trees
1 Easy
0 Medium
0 Hard
1 problems

Tree DFS with Global Max

Trees
0 Easy
0 Medium
1 Hard
1 problems

Tree DFS with Global Variable

Trees
1 Easy
0 Medium
0 Hard
1 problems

Tree DFS with Height Tracking

Trees
1 Easy
0 Medium
0 Hard
1 problems

Tree DFS with Max Tracking

Trees
0 Easy
1 Medium
0 Hard
1 problems

Tree DFS with Range

Trees
0 Easy
1 Medium
0 Hard
1 problems

Tree DFS/BFS with Encoding

Trees
0 Easy
0 Medium
1 Hard
1 problems

Tree Reconstruction

Trees
0 Easy
1 Medium
0 Hard
1 problems

Trie / DP

Trie
0 Easy
0 Medium
1 Hard
1 problems

Trie + Backtracking

Tries
0 Easy
0 Medium
1 Hard
1 problems

Trie Data Structure

Tries
0 Easy
1 Medium
0 Hard
1 problems

Trie with DFS

Tries
0 Easy
1 Medium
0 Hard
1 problems

Two Heaps

Heap / Priority Queue
0 Easy
0 Medium
1 Hard
1 problems

Two Pointers

Two Pointers
3 Easy
4 Medium
1 Hard
8 problems

Two Pointers (Gap)

Linked List
0 Easy
1 Medium
0 Hard
1 problems

Two Pointers (Greedy)

Two Pointers
0 Easy
1 Medium
0 Hard
1 problems

Two Pointers / Linked List

Linked List
1 Easy
0 Medium
0 Hard
1 problems

Two Pointers / Merge

Linked List
1 Easy
0 Medium
0 Hard
1 problems

Two Pointers / Sliding Window

Strings
0 Easy
0 Medium
1 Hard
1 problems

Two Pointers with Sorting

Two Pointers
0 Easy
1 Medium
0 Hard
1 problems

Union Find

Graphs
0 Easy
1 Medium
0 Hard
1 problems

Ready to Test Your Skills?

Take a quiz to see how well you recognize these patterns

Start Quiz