Free · Patterns first · Six languages
Coding interview practiceEarly access
Learn the pattern, write its template from memory, then solve problems against the clock in an editor in the page. Every solution is given in Python, C++, Java, JavaScript, Rust and Haskell, and every one is compiled and tested before it is published.
Start a timed interview Which pattern? →
- 8
- patterns
- 24
- problems
- 6
- languages
seen = {} # key -> whatever you need back
for i, x in enumerate(a):
key = derive(x) # the whole problem is choosing this
if key in seen:
use(seen[key], i) # look up BEFORE inserting, or you match x with itself
seen[key] = iunordered_map<long long, int> seen; // key -> whatever you need back
for (int i = 0; i < (int)a.size(); i++) {
long long key = derive(a[i]); // the whole problem is choosing this
auto it = seen.find(key);
if (it != seen.end()) use(it->second, i); // look up before inserting
seen[key] = i;
}Map<Long, Integer> seen = new HashMap<>(); // key -> whatever you need back
for (int i = 0; i < a.length; i++) {
long key = derive(a[i]); // the whole problem is choosing this
Integer prev = seen.get(key);
if (prev != null) use(prev, i); // look up before inserting
seen.put(key, i);
}const seen = new Map(); // key -> whatever you need back
for (let i = 0; i < a.length; i++) {
const key = derive(a[i]); // the whole problem is choosing this
if (seen.has(key)) use(seen.get(key), i); // look up before inserting
seen.set(key, i);
}let mut seen: HashMap<i64, usize> = HashMap::new(); // key -> what you need back
for (i, &x) in a.iter().enumerate() {
let key = derive(x); // the whole problem is choosing this
if let Some(&prev) = seen.get(&key) { use_it(prev, i); } // look up before inserting
seen.insert(key, i);
}import qualified Data.Map.Strict as M
-- fold the array, carrying the map and the answer together
solve :: [Int] -> Int
solve = snd . foldl step (M.empty, 0) . zip [0 ..]
where
step (seen, acc) (i, x) =
let key = derive x -- the whole problem is choosing this
acc' = case M.lookup key seen of -- look up before inserting
Just prev -> use prev i acc
Nothing -> acc
in (M.insert key i seen, acc')
The patterns
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.
Learn the pattern → 023 problemsTwo pointers
Two indices walking a sorted or paired structure, each step ruling out one candidate for good.
Learn the pattern → 032 problemsSliding window
A window that grows on the right, shrinks on the left, and holds an invariant at all times.
Learn the pattern → 042 problemsBinary search
Search the answer, not the array: halve a monotone predicate until one candidate is left.
Learn the pattern → 052 problemsDynamic programming
Write the recursion, notice the repeats, fill a table in an order that makes each entry final.
Learn the pattern → 063 problemsStack
Keep the elements whose question is still open; each new element settles the ones it beats and waits its turn.
Learn the pattern → 073 problemsHeap (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).
Learn the pattern → 083 problemsBacktracking
Build a solution one choice at a time, and abandon a branch the moment it cannot succeed.
Learn the pattern →How it works
- Learn the patternEach section opens with when the pattern applies and a template you should be able to write without thinking. Most interview bugs are deviations from it.
- Solve in the pageAn editor with the function signature ready, your code run against the real test table, and hints you open only if you need them.
- Then do it under pressureInterview mode gives you a window sized to the difficulty, a limited number of runs and submissions, and a report at the end showing where the marks went.
Common questions
Which languages are covered?
Every problem carries a full solution in Python, C++, Java, JavaScript, Rust and Haskell. The in-page editor runs JavaScript today; the other languages are there to read, compare and copy. Python in the browser is coming.
Are the solutions actually tested?
Yes. Before publishing, every Python and JavaScript solution is run against the full test table, and the C++, Rust and Haskell solutions are compiled and executed. Java is reviewed by hand, because there is no Java toolchain on the build machine.
What is interview mode?
A closer simulation of the real thing: a fixed window by difficulty, a limited number of runs and submissions, penalties for failed submissions and for opening hints, and a report at the end with your score, the deductions and your submission history.
Is this for quant interviews or software interviews?
Both. The patterns are the same; the flavour differs. Trading firms weight implementation speed and edge cases more heavily, and often ask you to talk through complexity as you type.
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.