Practice · Coding interviews
Coding interview course
10 modules, taken in order. Each opens with the pattern and a template short enough to write from memory, explains why the obvious approach is too slow, then gives you problems to solve in an editor in the page, in Python, C++, Java, JavaScript, Rust or Haskell.
- 10 modules
- 93 lessons
- 195 problems
- 6 languages
- timed exam with a report
Not sure which pattern a problem needs? The decision flowchart narrows it down in a few questions.
Course outline
The order matters more than people expect: each module assumes the argument made in the one before it, and the exam draws on all of them.
-
01309 min
Arrays and hashing
Trade memory for time: a hash map answers "have I seen this?" in O(1), and most array problems reduce to asking it the right question.
- Lesson Overview and template 5 min
- Lesson Understanding the problem 7 min
- Lesson What to remember about the past 10 min
- Problem Pair with a given sum in an unsorted array Easy 10 min
- Problem A repeated value within k positions Easy 10 min
- Problem Longest run of consecutive integers Medium 15 min
- Problem Can one word be renamed into another? Easy 15 min
- Problem Is this Sudoku board valid so far? Medium 15 min
- Lesson Count tables 10 min
- Problem Are two words anagrams? Easy 10 min
- Problem The k most frequent values Medium 15 min
- Problem Group the words that are anagrams Medium 20 min
- Problem Cut a note out of a magazine Easy 10 min
- Lesson Prefix sums as keys 12 min
- Problem Count subarrays with a given sum Medium 20 min
- Problem Product of every element except itself Medium 15 min
- Problem Longest subarray with a given sum Medium 20 min
- Problem Count subarrays with a sum divisible by k Medium 20 min
- Lesson The array as its own table 10 min
- Problem Smallest positive integer that is missing Hard 25 min
- Problem Find every value that appears twice Medium 20 min
- Problem Find every number from 1 to n that is missing Easy 15 min
-
02439 min
Two pointers
Two indices walking a sorted or paired structure, each step ruling out one candidate for good.
- Lesson Overview and template 5 min
- Lesson Understanding the problem 6 min
- Lesson Pointers from both ends 11 min
- Problem Pair with a given sum in a sorted array Easy 10 min
- Problem Count the pairs whose sum is below a target Easy 12 min
- Problem A palindrome, ignoring punctuation and case Easy 10 min
- Problem A palindrome after deleting at most one letter Easy 12 min
- Problem Squares of a sorted array, in order Easy 10 min
- Problem Two walls holding the most water Medium 15 min
- Problem Fewest boats under a weight limit Medium 15 min
- Problem Subsequences whose smallest and largest fit a target Medium 20 min
- Problem Rain water trapped between walls Hard 25 min
- Problem The shortest part to sort so the whole array is sorted Medium 15 min
- Problem The next permutation, in place Medium 20 min
- Lesson A reader and a writer 10 min
- Problem Move the zeros to the end Easy 10 min
- Problem Keep each value at most twice Medium 15 min
- Problem Merge two sorted arrays Easy 10 min
- Problem Is one string a subsequence of another Easy 10 min
- Problem The smallest difference between two arrays Medium 15 min
- Problem Sort three colours in one pass Medium 15 min
- Problem Two strings equal after their backspaces Easy 12 min
- Lesson Fix one, then two pointers 10 min
- Problem All distinct triplets summing to zero Medium 20 min
- Problem The triple sum closest to a target Medium 20 min
- Problem Count the triplets with a sum below a target Medium 15 min
- Problem Count the triangles you can make Medium 15 min
- Problem All distinct quadruplets with a given sum Medium 20 min
- Lesson Fast and slow pointers 11 min
- Problem The repeated number, without changing the array Medium 20 min
- Problem Does the digit-square sequence reach 1 Easy 10 min
- Problem Where a linked list loops back on itself Medium 15 min
-
03480 min
Sliding window
A window that grows on the right, shrinks on the left, and holds an invariant at all times.
- Lesson Overview and template 5 min
- Lesson Understanding the problem 7 min
- Lesson Fixed and variable windows 10 min
- Lesson Fixed-size windows 10 min
- Problem Best total over k consecutive days Easy 10 min
- Problem Most vowels in any k letters Easy 10 min
- Problem Every place an anagram begins Medium 20 min
- Problem Distinct values in every window Medium 15 min
- Problem The best stretch to stay calm Medium 15 min
- Lesson The longest valid window 12 min
- Problem Longest run of tasks within a time budget Easy 12 min
- Problem Longest run of distinct characters Medium 15 min
- Problem Longest run with at most k distinct letters Medium 20 min
- Problem Longest run of ones after k flips Medium 15 min
- Problem Longest run of one letter after k changes Medium 25 min
- Problem Longest run of ones after deleting one element Medium 15 min
- Lesson The shortest valid window 10 min
- Problem Shortest subarray with a sum at least the target Medium 15 min
- Problem Shortest window holding every kind Medium 20 min
- Problem Shortest window containing every letter Hard 30 min
- Lesson Counting windows 12 min
- Problem Count runs whose product is below k Medium 20 min
- Problem Count substrings holding a, b and c Medium 20 min
- Problem Count runs with exactly k distinct values Hard 30 min
- Lesson The monotone deque 12 min
- Problem Maximum of every window Hard 25 min
- Problem Longest run whose spread is at most a limit Medium 25 min
- Problem Shortest run with sum at least K, negatives allowed Hard 35 min
- Lesson When a window is the wrong tool 10 min
-
04739 min
Binary search
Search the answer, not the array: halve a monotone predicate until one candidate is left.
- Lesson Overview and template 5 min
- Lesson Understanding the problem 7 min
- Lesson The test that switches once 9 min
- Lesson Three templates and their invariants 12 min
- Lesson Checking a binary search before you run it 8 min
- Lesson Searching a sorted array 9 min
- Problem Find a value in a sorted array Easy 10 min
- Lesson Lower and upper bounds 11 min
- Problem Where a value belongs in a sorted array Easy 10 min
- Problem First and last position of a value Medium 15 min
- Problem Count the partners that clear a threshold Medium 20 min
- Problem Research impact from sorted citation counts Medium 15 min
- Lesson Searching a range of answers 10 min
- Lesson When there is no upper bound 7 min
- Lesson Searching real numbers 8 min
- Problem Integer square root without a library Easy 10 min
- Problem Complete rows of a coin staircase Easy 10 min
- Lesson Rotated sorted arrays 11 min
- Problem Minimum of a rotated sorted array Medium 15 min
- Problem Find a value in a rotated sorted array Medium 20 min
- Problem Search a rotated array with repeated values Medium 20 min
- Lesson Peaks and pairs: testing a neighbour 10 min
- Problem The top of a mountain array Easy 10 min
- Problem The one value without a partner Medium 15 min
- Problem Find a value in a mountain array Hard 25 min
- Lesson Sorted matrices 9 min
- Problem Search a matrix sorted in reading order Medium 15 min
- Problem Search a matrix sorted along rows and columns Medium 20 min
- Lesson Two sorted arrays 13 min
- Problem The k-th smallest of two sorted arrays Hard 25 min
- Problem Median of two sorted arrays Hard 30 min
- Lesson The pattern: minimise the maximum 12 min
- Problem Smallest ship that clears the backlog in D days Medium 20 min
- Problem The slowest rate that clears every queue in time Medium 20 min
- Problem The first day enough adjacent flowers are open Medium 20 min
- Problem Earliest time a fleet completes its trips Medium 20 min
- Problem Least time for a workshop to repair every car Medium 25 min
- Problem Split an array to minimise the largest part Hard 30 min
- Lesson The pattern: maximise the minimum 11 min
- Problem Spread m items to maximise the closest pair Medium 25 min
- Problem The largest equal share for k people Medium 20 min
- Problem Longest time n machines can run on shared batteries Hard 30 min
- Lesson The pattern: the k-th smallest by counting 12 min
- Problem The k-th smallest value in a sorted matrix Medium 25 min
- Problem The k-th smallest entry of a multiplication table Hard 25 min
- Problem The k-th smallest distance between two values Hard 30 min
-
051245 min
Dynamic programming
Write the recursion, notice the repeats, fill a table in an order that makes each entry final.
- Lesson Overview and template 5 min
- Lesson Understanding the problem 8 min
- Lesson From a recursion tree to a graph of subproblems 10 min
- Lesson Choosing the state 10 min
- Lesson Writing the recurrence, and checking it 12 min
- Lesson Base cases 8 min
- Lesson Top-down and bottom-up 11 min
- Lesson Longest increasing subsequence 12 min
- Problem Longest increasing subsequence Medium 15 min
- Problem Longest increasing subsequence in O(n log n) Medium 25 min
- Lesson Longest common subsequence 12 min
- Problem Longest common subsequence Medium 15 min
- Lesson Longest common substring 9 min
- Problem Longest common block Medium 15 min
- Lesson Edit distance 11 min
- Problem Edit distance between two strings Hard 30 min
- Lesson The 0/1 knapsack 13 min
- Problem The 0/1 knapsack Medium 20 min
- Lesson The bounded knapsack 10 min
- Problem The bounded knapsack Medium 20 min
- Lesson The unbounded knapsack 9 min
- Problem The unbounded knapsack Medium 15 min
- Lesson Counting with a knapsack 9 min
- Problem Ways to make an amount Medium 15 min
- Lesson Longest palindromic subsequence 11 min
- Problem Longest palindromic subsequence Medium 20 min
- Lesson Longest palindromic substring 10 min
- Problem Longest palindromic substring Medium 20 min
- Lesson Palindrome partitioning 10 min
- Problem The fewest cuts into palindromes Hard 25 min
- Lesson Matrix chain multiplication 11 min
- Problem The cheapest order to multiply matrices Hard 25 min
- Lesson Linear DP: one entry per position 9 min
- Problem The cheapest way up a staircase Easy 10 min
- Problem Can you reach the last position? Medium 15 min
- Problem Largest sum with no two chosen positions adjacent Medium 15 min
- Problem Ways to decode a string of digits Medium 20 min
- Lesson The best segment ending here 9 min
- Problem The largest-sum subarray Medium 15 min
- Problem One trade: the best profit Easy 10 min
- Problem The largest product of a subarray Medium 20 min
- Problem The largest sum on a circle Medium 20 min
- Lesson Subsequence DP: the best chain ending here 9 min
- Problem The largest chain of divisors Medium 20 min
- Problem How many longest increasing subsequences Medium 25 min
- Problem The longest rise-then-fall subsequence Medium 20 min
- Problem The longest alternating subsequence Medium 20 min
- Lesson Grid DP: cells filled from their neighbours 9 min
- Problem The cheapest path through a grid Medium 15 min
- Problem Paths around obstacles Medium 15 min
- Problem The largest square of ones Medium 20 min
- Problem The least starting health Hard 30 min
- Lesson Two-sequence DP: a table of prefix pairs 9 min
- Problem How many times one string appears in another Hard 25 min
- Problem Is a string an interleaving of two others? Medium 25 min
- Problem Wildcard pattern matching Hard 30 min
- Problem The shortest common supersequence Medium 20 min
- Lesson The 0/1 knapsack pattern 9 min
- Problem Can a subset reach the target? Medium 15 min
- Problem Split into two equal halves Medium 15 min
- Problem The smallest difference between two groups Medium 20 min
- Lesson The bounded knapsack pattern 9 min
- Problem The fewest coins from a limited supply Medium 20 min
- Problem Ways to pay with a limited supply Medium 20 min
- Lesson The unbounded knapsack pattern 9 min
- Problem Fewest coins to make an amount Medium 20 min
- Problem Split an integer for the largest product Medium 15 min
- Problem Cut a rod for the most money Medium 15 min
- Lesson The counting knapsack pattern 9 min
- Problem Ordered ways to reach a total Medium 15 min
- Problem Dice rolls with a target sum Medium 20 min
- Problem Subsets with a given sum Medium 15 min
- Lesson The palindrome pattern 9 min
- Problem Count the palindromic substrings Medium 15 min
- Problem The fewest insertions to make a palindrome Hard 20 min
- Lesson Interval DP: try every split 9 min
- Problem Burst balloons for the most coins Hard 30 min
- Problem The cheapest way to cut a stick Hard 30 min
- Problem Can the first player win? Medium 20 min
-
06172 min
Stack
Keep the elements whose question is still open; each new element settles the ones it beats and waits its turn.
- Lesson Overview and template 5 min
- Lesson Understanding the problem 7 min
- Lesson Matching and cancelling 9 min
- Problem Balanced brackets Easy 10 min
- Problem Asteroids that collide in a row Medium 15 min
- Lesson The monotonic stack 11 min
- Problem Days until a warmer day Medium 15 min
- Problem How many days in a row the price was no higher Medium 15 min
- Problem The sum of the minimum of every subarray Medium 20 min
- Problem Largest rectangle in a bar chart Hard 25 min
- Problem Evaluate reverse Polish notation Medium 15 min
- Problem A calculator for plus, minus and brackets Hard 25 min
-
0768 min
Heap (priority queue)
Keep the few elements that matter in a structure that hands you the smallest (or largest) in O(1) and updates in O(log n).
-
0870 min
Backtracking
Build a solution one choice at a time, and abandon a branch the moment it cannot succeed.
-
0991 min
Intervals
Sort by start to merge and count overlaps; sort by end to choose. One sorted pass replaces checking every pair.
- Lesson The pattern and its template 5 min
- Lesson Understanding the problem 8 min
- Problem Total time covered by a set of bookings Easy 12 min
- Problem Fewest meeting rooms for a day of meetings Medium 18 min
- Problem Fewest bookings to cancel so none overlap Medium 18 min
- Problem Most profit from jobs that do not overlap Hard 30 min
-
10948 min
Graphs
Grids, networks and dependencies are all graphs. Breadth-first search finds shortest paths, depth-first search and union-find find what is connected, Dijkstra handles weighted edges, and a queue of nodes with no remaining prerequisites gives an order.
- Lesson Overview and template 5 min
- Lesson Why graphs: data that a list cannot hold 8 min
- Lesson The vocabulary of graphs 7 min
- Lesson Kinds of graphs 8 min
- Lesson The adjacency matrix 7 min
- Lesson The adjacency list 8 min
- Problem Adjacency matrix to adjacency list Easy 8 min
- Problem The person everyone trusts Easy 10 min
- Lesson Depth-first traversal 10 min
- Lesson Breadth-first traversal 10 min
- Problem Depth-first order of a graph Easy 12 min
- Problem Breadth-first order of a graph Easy 12 min
- Lesson Grids as graphs 11 min
- Problem Repaint a region of an image Easy 10 min
- Problem Capture the enclosed regions Medium 20 min
- Lesson Cycles in an undirected graph 8 min
- Problem Does an undirected graph contain a cycle? Easy 12 min
- Lesson Cycles in a directed graph 9 min
- Problem Does a directed graph contain a cycle? Medium 15 min
- Lesson Topological sort 12 min
- Problem Can every course be finished? Medium 20 min
- Problem An order to take every course Medium 20 min
- Lesson Dijkstra's algorithm 13 min
- Problem Shortest distances from one node Medium 20 min
- Problem Time for a signal to reach every node Medium 25 min
- Lesson Negative edges and Bellman–Ford 12 min
- Problem Shortest distances with negative edges Medium 20 min
- Problem Cheapest fare with at most k stops Medium 25 min
- Lesson All pairs: the Floyd–Warshall algorithm 10 min
- Problem Distances between every pair of nodes Medium 15 min
- Problem The city with the fewest neighbours within reach Medium 20 min
- Lesson Union-find (disjoint set union) 11 min
- Problem The connection that closes a loop Medium 15 min
- Problem Moving cables to connect a network Medium 20 min
- Lesson Minimum spanning trees: Kruskal's and Prim's algorithms 10 min
- Problem Connect every point at the least cost Medium 25 min
- Lesson Maximum flow and the min-cut theorem 9 min
- Lesson Ford–Fulkerson, residual graphs and reverse edges 13 min
- Problem Maximum flow through a network Hard 30 min
- Lesson Maximum bipartite matching 11 min
- Problem Place as many applicants as possible Medium 25 min
- Lesson The depth-first search pattern: exploring every path 10 min
- Problem Every route from source to target Medium 20 min
- Problem Routes with an exact total weight Medium 20 min
- Problem Routes that visit every node once Hard 30 min
- Lesson The connected components pattern 9 min
- Problem Count the islands in a grid Easy 12 min
- Problem The largest island Medium 15 min
- Problem Count the friend groups Medium 15 min
- Problem The cheapest node in each group Medium 15 min
- Lesson The two-colouring pattern 9 min
- Problem Can the graph be split in two? Medium 15 min
- Problem Split people who dislike each other Medium 15 min
- Lesson Shortest paths by breadth-first search 11 min
- Problem Shortest path through a grid Medium 18 min
- Problem Distance to the nearest zero Medium 20 min
- Problem Minutes until every orange rots Medium 18 min
- Problem Shortest word transformation Hard 30 min
- Problem Shortest path with walls you may break Hard 30 min
- Lesson Shortest paths by Dijkstra: beyond plain distances 10 min
- Problem The path with the least effort Medium 25 min
- Problem Swim in rising water Hard 30 min
How it works
When it applies, the signals in the question that point to it, and a template you should be able to write without thinking. Most interview bugs are deviations from the template made without a reason.
An editor with the signature ready, your code compiled and run against the real test table, and hints you open only if you need them. Solutions in all six languages, every one tested before publication.
Exam mode gives you a window sized to the difficulty, a limited number of runs and submissions, and a report showing where the marks went. Solving alone and solving while the clock runs are different skills.
Exam mode
Pick a set and it starts here, in this page. Nothing is saved to an account and nothing is sent anywhere — the report is yours.
Choose a set
The rules
- Easy problems get 12 minutes, medium 20, hard 30.
- 8 runs and 3 submissions per problem.
- A failed submission costs 15 marks; opening a hint costs 10.
- Opening the solution scores the problem zero, as it would in a real screen.
Write a solution and run it against the real test table.
Common questions
Do I need an account?
No. Every lesson and every problem is open, with its solutions in all six languages, the timed interview mode and Ask AI.
Which languages are covered?
Python, C++, Java, JavaScript, Rust and Haskell. Every solution is given in all six, and each one is compiled and run against the problem’s test table before it is published — so what you read is what passed.
Do I need to know a pattern before I start?
No. Each module opens with when the pattern applies and a template short enough to write from memory, then a lesson on why the obvious approach is too slow, and only then the problems.
What is exam mode?
A timed screen with the constraints of a real one: a window sized to each problem, a limited number of runs and submissions, a penalty for a failed submission, and a report at the end showing where the marks went. It runs in this page.
Is this for quant interviews or software interviews?
Both. The patterns are the same ones tested at trading firms and at large technology companies. The difference at a quant desk is the follow-up questions about complexity and numerical care, which the solutions address as they go.
How long does it take?
About 76 hours of reading and solving if you work through it in order, which is the way it is meant to be used. Most people come back to the exam several times.
Want someone watching how you code?
The gap between solving a problem alone and solving it while someone interrupts you is the whole interview. I run mock interviews one to one, and I have sat on both sides of them.