Data structures & algorithms

Learn the pattern,
not 500 problems.

Most interview problems are one of about eighteen patterns in disguise. Learn to recognise them, watch each one run step by step, then practise on a curated ladder.

18patterns
143problems
18visualizers
  1. 01

    Get the idea

    An everyday analogy and the one insight that makes the pattern fast.

  2. 02

    Watch it run

    Step through the algorithm line by line, or type your own input.

  3. 03

    Solve the ladder

    6–8 LeetCode problems, easy to hard, with hints that don't spoil it.

  4. 04

    Get grilled

    Run a mock interview on the pattern and get an honest score.

Roadmap

Ordered by prerequisite.

Go top to bottom the first time. Each pattern leans on the ones before it.

Arrays & Strings

Linked Lists

Heaps

Trees

Graphs

Recursion & DP

Cheatsheet

“Which pattern is this?”

Read the problem, find the phrase, jump to the pattern. The fastest way to stop staring at a blank editor.

If the problem says…Reach for
sorted array · find a pair (or triplet) that sums to target · in-place, O(1) extra spaceTwo Pointers
contiguous subarray / substring · longest / shortest / maximum window such that… · at most k distinct charactersSliding Window
subarray sum equals k · count the number of subarrays · contains negative numbersPrefix Sum + Hash Map
sorted array / rotated sorted array · find the first / last position of · minimum capacity / speed / time such that…Binary Search
next greater / next smaller element · how many days until a warmer temperature · previous less elementMonotonic Stack
list of intervals [start, end] · merge overlapping · insert a new intervalMerge Intervals
can you reach the end · minimum number of jumps / steps · maximize profit with unlimited transactionsGreedy
linked list has a cycle · find where the cycle begins · middle of the linked listFast & Slow Pointers
reverse the linked list · reverse between positions left and right · reverse in groups of kIn-place Reversal
kth largest / kth smallest · top k frequent · k closest pointsHeap / Top-K
level order / level by level · right side view / left view · minimum depth / shortest path in a treeTree BFS (Level Order)
maximum depth / height · diameter / longest path · path sum from root to leafTree DFS (Recursion)
2-D grid of '1's and '0's · number of islands / connected regions · shortest path in a maze / unweighted graphGraph BFS / DFS (Grids)
prerequisites / dependencies · can you finish all courses · valid build / task orderTopological Sort
number of connected components / provinces · edges arrive one by one (dynamic connectivity) · redundant connection / creates a cycleUnion-Find (DSU)
return all possible subsets / combinations / permutations · generate all valid … · each number may be used once / unlimited timesBacktracking
maximum / minimum total with a restriction · number of ways to reach / decode · cannot pick adjacent elements1-D Dynamic Programming
two strings / two sequences · longest common subsequence · minimum edits to convert2-D Dynamic Programming