Courses / DSA Patterns for Working Engineers / Chapter 1
Module 1 · The coding interview · Chapter 1 of 39
The Coding Interview: How the Round Runs and How to Prepare
Start here. Next up: Two Pointers: Pairs, Partitions and In-Place Scans.
Part 1 · How a coding round runs
Formats of a coding round
A coding round gives you one or two problems you have probably not seen, a shared editor and a fixed amount of time. Companies run the same idea in a few different formats, and it helps to know which one you are walking into.
| Format | Where it happens | Typical length | What it is for |
|---|---|---|---|
| Online assessment | A browser editor, no person present | 60 to 120 minutes, often 2 to 3 problems | Filter many candidates with hidden test cases |
| Phone or video screen | Shared editor and a call | 30 to 45 minutes, one or two problems | Check that you can solve and explain a problem |
| Onsite or virtual loop | Several back-to-back rounds | 45 to 60 minutes each | Go deeper, compare you against the same bar as others |
| AI-assisted round | Editor with an assistant and a small codebase | About 60 minutes | See how you read, test and fix code with help |
Where it happensA browser editor, no person present
Typical length60 to 120 minutes, often 2 to 3 problems
What it is forFilter many candidates with hidden test cases
The clock inside a 45-minute round
Whatever the format, the time inside a round splits into the same phases. A rough budget for a 45-minute round with one problem looks like this.
| Phase | Minutes | What you do |
|---|---|---|
| Understand | 3 to 5 | Restate the problem, ask about limits and edge cases, work one example by hand |
| Plan | 5 to 8 | Say a brute-force idea, find the bottleneck, choose a better approach, state its cost |
| Code | 15 to 20 | Write the solution in small named functions, saying what each part does |
| Test | 5 to 8 | Trace one example through the code, then try the edge cases you listed |
| Wrap up | 2 to 3 | State time and space cost, name one improvement, take questions |
Notice that coding is less than half of the time. Typing in the first minute, before the limits and edge cases are known, often ends with a rewrite in the last ten. The phases are a budget, not a script: a simple problem lets you move through planning in two minutes and spend the time on tests.
A template to start every practice session
Practice under the same conditions as the round. Every problem in this course uses the same layout: a function, a few node:test cases written next to it, and a single command that runs them. The file below is the smallest version. It finds the first id that appears twice in a registration export.
import test from 'node:test' import assert from 'node:assert/strict' export function firstRepeat(ids: string[]): string | null { const seen = new Set<string>() for (const id of ids) { if (seen.has(id)) return id seen.add(id) } return null } test('finds the first id that appears twice', () => { assert.equal(firstRepeat(['a1', 'b2', 'a1', 'b2']), 'a1') }) test('returns null when nothing repeats', () => { assert.equal(firstRepeat(['a1', 'b2']), null) })
Save as first-repeat.test.ts and run node --test first-repeat.test.ts
Node 24 runs TypeScript files directly by stripping the type annotations, so there is no build step. The node:test runner finds the tests and prints one line for each.
✔ finds the first id that appears twice (0.694ms) ✔ returns null when nothing repeats (0.1272ms) ℹ tests 2 ℹ pass 2 ℹ fail 0
Output of one run on this machine; the times in brackets vary
a1 is not in the set yet, so it is added
Read it as steps
A set records each id until one arrives twice
The scene shows what the function does: each id is added to the set until b2 arrives a second time. Ids are shown short. In a real export each id would be an email address.
Part 2 · What the interviewer scores
The four areas
Interviewers fill in a form after the round, and the form is usually a short list of areas with a rating for each. The Tech Interview Handbook publishes a rubric that many people use as a model. It names four areas: communication, problem solving, technical competency and testing. Companies word these differently, but nearly every form covers the same ground.
| Area | A strong signal | A weak signal |
|---|---|---|
| Communication | You ask clarifying questions and explain your reasoning while you work | Long silences, or coding before the problem is clear |
| Problem solving | You reach a sound approach, compare options and state their costs | You jump to code, or stay stuck on one idea |
| Technical competency | Clean, working code turned out at a steady pace, with helpful names | Syntax fights, repeated rewrites, code you cannot explain |
| Testing | You check typical and edge cases and find your own bugs | You declare it done without running anything |
Two things follow from this. First, a correct solution alone is one of four areas. Second, three of the four areas can be practised without learning any new algorithm: say your thinking aloud, name the cost, and test. The mock chapter scores each area from 1 to 4, where 1 is the weak signal in the table and 3 is the strong one.
What each area looks like in the room
Communication starts with the first minute. Restate the problem in your own words and ask about the input: can it be empty, can values repeat, how large can it get. Those questions are scored, and the answers about size also tell you what cost you can afford.
Problem solving is visible in the order you work. A brute-force idea said aloud shows you understand the problem. Naming what makes it slow shows you can analyse it. Only then does a better idea count as your own, rather than something recalled.
Technical competency is the code itself. Use short functions, names that say what a value means, and the language features you know well. Choosing a plainer construct you can write correctly beats a clever one you cannot.
Testing is the area people forget. Pick the cases before you run them: an empty input, one element, all elements equal, and the largest input you can imagine. When a test fails, say what you expected, what you got and which line you suspect. A bug found and fixed this way scores well. A bug found by the interviewer does not.
Tests first, shown with a failing run
The cheapest way to show testing is to write the tests first, watch them fail, then write the code. Below, the function is a longest run of equal neighbours. The first version is a stub that returns zero, so the tests must fail.
import test from 'node:test' import assert from 'node:assert/strict' import { longestRun } from './longest-run.ts' test('empty input has no run', () => { assert.equal(longestRun([]), 0) }) test('a single value is a run of one', () => { assert.equal(longestRun([9]), 1) }) test('picks the longest of several runs', () => { assert.equal(longestRun([4, 4, 4, 7, 7, 4]), 3) })
✔ empty input has no run (0.5884ms) ✖ a single value is a run of one (0.5939ms) ✖ picks the longest of several runs (0.1543ms) ℹ tests 3 ℹ pass 1 ℹ fail 2 assertion messages: 0 !== 1 0 !== 3
Stub: the first test passes by luck, the other two fail
Now the real function. It keeps the length of the current run and the best run so far.
// Longest run of equal neighbours: [4, 4, 4, 7, 7] -> 3 export function longestRun(xs: number[]): number { let best = 0 let run = 0 for (let i = 0; i < xs.length; i++) { run = i > 0 && xs[i] === xs[i - 1] ? run + 1 : 1 best = Math.max(best, run) } return best }
✔ empty input has no run (0.6219ms) ✔ a single value is a run of one (0.1289ms) ✔ picks the longest of several runs (0.0977ms) ℹ tests 3 ℹ pass 3 ℹ fail 0
The same tests against the real function
Failing first proves the tests can fail. A test that has never failed might not be testing anything.
Common mistakes
The same few mistakes lose marks in round after round. They are easy to fix once you know them.
- Coding before the problem is clear. Two minutes of questions cost less than ten minutes of rewriting.
- Going silent. The interviewer cannot score thinking they cannot hear, so say what you are trying and why.
- Stopping at brute force, or jumping straight to a pattern you cannot justify. Show the bottleneck between the two.
- Never running the code. Trace one example by hand, or run it, before you say you are done.
- Ignoring edge cases: an empty input, one element, all elements equal, a value at either end of the range.
- Defending a wrong idea. If a test fails or a hint arrives, say what changed and adjust.
A useful habit is to keep a short list of the edge cases you always check and read it aloud before you start testing. It turns testing from a hope into a step.
Check yourself
Name the four areas a common public rubric scores.
- Communication, problem solving, technical competency and testing.
Why does a stub that returns 0 make a good first step?
- It shows the tests can fail, so a later pass means something.
- It also fixes the function signature before any logic is written.
The stub passed the empty-input test. What does that tell you about that test on its own?
- It cannot tell the stub from a correct solution, so a pass there proves little.
- Tests that expect a non-zero answer, like the single value and the several runs, are the ones that show the logic works.
Part 3 · A method for problems you have not seen
Six steps from problem to checked solution
When a problem is new, a fixed sequence keeps you from freezing. It is built from the advice on the Tech Interview Handbook plus one step that is easy to skip: a stress test. Each step has an output you can say aloud.
- Restate and ask. Say the problem back, then ask about size, duplicates, empty input and what to return when there is no answer.
- Work two examples by hand. One normal and one edge case. Write the answers down; they become your tests.
- Brute force first, with tests. The simplest code that is obviously correct. It gives you a baseline and, later, an oracle.
- Name the bottleneck. Which repeated work makes the brute force slow? That sentence points at the pattern.
- Apply a pattern and state the cost. Replace the repeated work using the idea the bottleneck suggests, then say time and space.
- Stress test against the brute force. Run both on thousands of small random inputs and compare.
Take Two Sum as an example of the fourth step. The brute force checks every pair, so for each number it searches the rest of the list for the partner. The repeated work is that search. Once you say that, the pattern follows: a structure that answers "have I seen this value?" in one step, which is a hash map. The cost drops from n squared to n, and you spent one sentence getting there.
The last step is the one this course adds. A hand-written example catches the bugs you thought of. Random inputs catch the ones you did not.
A seeded random generator
A stress test needs random input that you can repeat. If a test fails on round 1,380 you want to run exactly that round again. So the generator takes a seed, a number that fixes the whole sequence. The one used throughout this course is mulberry32, a tiny generator that returns a number between 0 and 1 each time you call it.
export function mulberry32(seed: number): () => number { let a = seed >>> 0 return () => { a = (a + 0x6d2b79f5) >>> 0 let t = a t = Math.imul(t ^ (t >>> 15), t | 1) t ^= t + Math.imul(t ^ (t >>> 7), t | 61) return ((t ^ (t >>> 14)) >>> 0) / 4294967296 } }
The details of the arithmetic do not matter for a round; what matters is that the same seed always gives the same sequence, so a failure is reproducible. Save it as rng.ts: every stress test in this course imports it from there and starts with mulberry32(2024) or another fixed seed, and the same idea is used for the checks that compare a fast solution with a slow one.
A stress test that catches a planted bug
The task: the largest sum of two elements at different positions. The brute force tries every pair. The fast version tracks the two largest values in one pass. It has a bug planted on purpose: the starting values are 0, which is wrong when the numbers are negative.
// Largest sum of two elements at different positions. export function bruteTwoLargest(xs: number[]): number { let best = -Infinity for (let i = 0; i < xs.length; i++) for (let j = i + 1; j < xs.length; j++) best = Math.max(best, xs[i] + xs[j]) return best } export function fastTwoLargest(xs: number[]): number { let a = 0 // planted bug: should start at -Infinity let b = 0 for (const x of xs) { if (x > a) { b = a; a = x } else if (x > b) b = x } return a + b }
The stress test generates arrays of 2 to 6 numbers between -9 and 9, compares the two functions and stops at the first disagreement.
import { mulberry32 } from './rng.ts' import { bruteTwoLargest, fastTwoLargest } from './two-largest.ts' const rand = mulberry32(2024) const pick = (lo: number, hi: number) => lo + Math.floor(rand() * (hi - lo + 1)) for (let round = 1; round <= 2000; round++) { const n = pick(2, 6) const xs = Array.from({ length: n }, () => pick(-9, 9)) const want = bruteTwoLargest(xs) const got = fastTwoLargest(xs) if (want !== got) { console.log(`round ${round}: input ${JSON.stringify(xs)}`) console.log(`brute ${want}, fast ${got}`) process.exit(1) } } console.log('2000 rounds agree')
round 2: input [-1,4] brute 3, fast 4
It failed on the second round: with [-1, 4] the brute force gives 3 and the fast version gives 4, because it paired 4 with a phantom 0. Starting both values at -Infinity fixes it, and the same test then reports 2000 rounds agree. A hand-picked example with positive numbers would never have shown this.
Related on LeetCode: Two Sum and Contains Duplicate are good first problems for practising the six steps.
What does a seed make possible in a stress test?
- The same sequence of random inputs on every run, so a failing round can be replayed.
Part 4 · Budgeting from the limits
Reading the size of the input
Most problems state a limit on the input size, usually called n. That number tells you which costs are affordable before you write any code. A simple loop body in a language like JavaScript runs somewhere between a few tens of crore and a few hundred crore simple steps per second, depending on the work in the body and the machine. The measurements below show where one machine sits, and a sensible plan stays well under it.
| Limit on n | Cost that fits | Typical approach |
|---|---|---|
| Up to about 12 for n factorial, 20 for 2^n | Exponential or factorial | Try every arrangement or subset |
| Up to about 5,000 | n squared | Two nested loops, simple table DP |
| Up to a few lakh to 10 lakh | n log n | Sort first, heap, binary search, divide and conquer |
| 10 lakh to a few crore | n | One pass, hash map, two pointers, prefix sums |
| Beyond that | log n or O(1) | Binary search on a sorted structure, a formula |
Memory is a budget too. A table with n rows and n columns for n = 5,000 has 2.5 crore cells, which is fine as numbers in a typed array and heavy as nested arrays of objects. If a limit is not given, ask for it. The answer shapes the solution, and asking is itself a good signal.
The rows are a rule of thumb. A heavy loop body, such as one that allocates objects, can cut the affordable step count by ten times.
Counting the work
Operation counters are better evidence than clocks, because they do not change from run to run. The function below tests every pair in a list of n different ids and counts the tests. It never finds a duplicate, so it does the worst-case work.
// Counts the comparisons a duplicate check makes by testing every pair. function pairChecks(n: number): number { const xs = Array.from({ length: n }, (_, i) => i) let checks = 0 for (let i = 0; i < n; i++) for (let j = i + 1; j < n; j++) { checks++ if (xs[i] === xs[j]) return checks } return checks } for (const n of [1000, 2000, 4000]) { console.log(`n = ${n}: ${pairChecks(n)} checks`) }
n = 1000: 499500 checks n = 2000: 1999000 checks n = 4000: 7998000 checks
Doubling n from 1,000 to 2,000 multiplies the checks by four, and doubling again multiplies them by four again. That is what quadratic growth looks like: the count is n times n minus 1, divided by 2, which is 4,99,500 for 1,000 values.
Now measure the speed of this machine. The loop below does 100 crore plain additions.
// How many plain additions this machine does per second. const start = performance.now() let total = 0 for (let i = 0; i < 1_000_000_000; i++) total += i & 1 const seconds = (performance.now() - start) / 1000 console.log(`10^9 additions: ${seconds.toFixed(2)} s (total ${total})`)
10^9 additions: 0.41 s (total 500000000) 10^9 additions: 0.41 s (total 500000000) 10^9 additions: 0.41 s (total 500000000)
Three runs on this machine; the times vary between machines and runs
From a count to a time
A count becomes a time when you divide by a rate. The plain addition loop above is the best case. The pair check itself, run at n = 40,000, gives a rate closer to the real work.
const n = 40000 const xs = Array.from({ length: n }, (_, i) => i) const start = performance.now() let checks = 0 for (let i = 0; i < n; i++) for (let j = i + 1; j < n; j++) { checks++ if (xs[i] === xs[j]) break } const s = (performance.now() - start) / 1000 const rate = (checks / s / 1e9).toFixed(2) console.log(`n = ${n}: ${checks} checks in ${s.toFixed(2)} s`) console.log(`${rate} billion checks per second`)
n = 40000: 799980000 checks in 0.39 s 2.03 billion checks per second n = 40000: 799980000 checks in 0.38 s 2.10 billion checks per second n = 40000: 799980000 checks in 0.38 s 2.09 billion checks per second
Three runs on this machine; the times vary
That is about 210 crore checks per second. The scene applies this rate to a nightly check for duplicates across 1 crore payment rows.
Time for the pair scan: 6.6 hours (on this machine; sorting the same 1 crore numbers took about 1.1 s)
Read it as steps
Pair counting turns a count into hours at a measured rate
The same job by sorting first needs about n log n steps, which is 2.3 x 10^8 for 1 crore rows. In four runs on this machine, sorting a 1 crore element typed array and scanning neighbours took 1.06 to 1.13 seconds. Checking with a Set took 4.9 to 5.3 seconds, which is slower than the sort even though it does less work on paper. Operation counts tell you the growth, and constant factors still decide between two solutions of the same growth or close to it. Both finish in seconds; the pair scan takes hours.
Part 5 · TypeScript on Node for coding rounds
Running a .ts file
Node 22.18 or later, and so Node 24, which the course is tested on, runs a TypeScript file directly: node solution.ts. It does this by type stripping, which deletes the annotations and runs the JavaScript that is left. Two consequences matter during a round.
First, only syntax that vanishes when the types are removed works. A TypeScript enum generates code, so Node refuses it.
SyntaxError [ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX]: TypeScript enum is not supported in strip-only mode
Running a file that declares an enum; the first line of the error, wrapped to fit
Use a union of string literals or a plain object instead, and avoid parameter properties and namespace blocks for the same reason.
Second, Node does not check types. A file with const n: number = 'seven' runs happily.
seven
Running a file that assigns a string to a number
Two rules about files follow from the same design. Imports between files keep the extension, as in import { solve } from "./solve.ts". Imports that only bring in types are written import type, so stripping can delete them safely. Leave out the type keyword and the file fails before it runs: importing a type Row that way from ./types.ts stopped with the error does not provide an export named 'Row', because at run time the module has no such export. Built-in modules use the node: prefix, as in node:test and node:assert/strict. Later chapters follow one code-block convention. A block that starts a file shows its imports. A block that shows only a function, a demo or a test belongs to the file named in the text and may leave its imports out. A test file begins with test from node:test, assert from node:assert/strict, mulberry32 from ./rng.ts when it needs one, and the code it tests.
If you want the checker, run the TypeScript compiler separately with tsc --noEmit. In a timed round, treat types as notes for yourself and rely on tests.
Traps that cost marks
JavaScript has a few behaviours that break algorithm code without any error. Each one below was run on this machine.
The default sort compares items as strings, so numbers sort in the wrong order unless you pass a comparator.
console.log([10, 9, 1, 100].sort()) console.log([10, 9, 1, 100].sort((a, b) => a - b))
[ 1, 10, 100, 9 ] [ 1, 9, 10, 100 ]
Numbers are 64-bit floats, so integers above 2^53 lose precision. Use BigInt when sums can pass Number.MAX_SAFE_INTEGER.
console.log(2 ** 53 === 2 ** 53 + 1) console.log(9007199254740993n, Number(9007199254740993n)) console.log(Number.MAX_SAFE_INTEGER)
true 9007199254740993n 9007199254740992 9007199254740991
Bitwise operators work on 32-bit signed integers, so 1 << 31 is negative and 2 ** 32 + 5 | 0 becomes 5.
console.log(1 << 31, 2 ** 31 | 0, 2 ** 32 + 5 | 0) console.log(2 ** 31 >>> 0, (2 ** 31) >> 1, (2 ** 31) >>> 1)
-2147483648 -2147483648 5 2147483648 -1073741824 1073741824
Built-ins worth knowing
Node 24 has several newer array and set methods that save lines and avoid mutation. toSorted returns a sorted copy and leaves the original alone. at(-1) reads the last element. findLast searches from the end. Object.groupBy buckets items by a key, and Set has a union method. All of these ran on Node 24.18 here.
const xs = [10, 9, 1, 100] console.log(xs.toSorted((a, b) => a - b), xs) console.log(xs.at(-1), xs.findLast((x) => x < 50)) const byParity = Object.groupBy(xs, (x) => (x % 2 ? 'odd' : 'even')) console.log(byParity) console.log(new Set([1, 2]).union(new Set([2, 3])))
[ 1, 9, 10, 100 ] [ 10, 9, 1, 100 ] 100 1 [Object: null prototype] { even: [ 10, 100 ], odd: [ 9, 1 ] } Set(3) { 1, 2, 3 }
Do not assume every new method exists. Math.sumPrecise, for example, is not defined on this version. When unsure, check with typeof before you rely on it, and keep a plain loop in mind as the fallback.
Stack depth and shift()
Recursion depth is limited. A function that calls itself with one argument, and does nothing else, ran out of stack after about 9,600 calls on Windows and about 9,630 in WSL on this machine, and the exact count moved by a few dozen between runs. The limit depends on the function and the machine, and the chapters that use recursion measure their own figures. A recursive solution that goes 1 lakh calls deep will overflow, so know how to write the loop version.
function depth(n: number): number { try { return depth(n + 1) } catch { return n } } console.log('frames before RangeError:', depth(0))
frames before RangeError: 9612One run on this machine
The other trap is Array.prototype.shift. It removes the first element but may have to move all the others, and in this run the time roughly quadrupled each time the size doubled. A queue built on shift() is fine for small inputs and slow for large ones. This course writes every queue as an array plus a head index that only moves forward.
function drainShift(n: number): number { const q = Array.from({ length: n }, (_, i) => i) let sum = 0 while (q.length) sum += q.shift() as number return sum } function drainHead(n: number): number { const q = Array.from({ length: n }, (_, i) => i) let sum = 0 for (let head = 0; head < q.length; head++) sum += q[head] return sum } function ms(f: () => unknown): string { const t = performance.now() f() return (performance.now() - t).toFixed(0) } for (const n of [25_000, 50_000, 100_000]) { const a = ms(() => drainShift(n)) const b = ms(() => drainHead(n)) console.log(`n = ${n}: shift ${a} ms, head index ${b} ms`) }
n = 25000: shift 26 ms, head index 1 ms n = 50000: shift 100 ms, head index 2 ms n = 100000: shift 422 ms, head index 6 ms
One run on this machine; the engine decides how shift behaves
Why does node solution.ts refuse an enum?
- Node only strips types. An enum needs generated code, so it is not supported in strip-only mode.
What replaces shift() in a breadth-first queue here?
- An array and a head index that only moves forward. Nothing is moved.
A solution sorts the scores [10, 9, 1, 100] with scores.sort(), then reads the smallest as scores[0] and the largest as scores.at(-1). The smallest is 1, which is right, but the largest comes out as 9. What happened, and what is the fix?
Part 6 · Spotting the pattern, and a study plan
A table from cue to chapter
Most problems tell you which tool to reach for in the way they are worded. The table below lists the common cues and the chapter of this course that covers each. It is a first guess to check against the problem, not a rule.
| The problem says or shows | Think of | Chapter |
|---|---|---|
| Sorted array, find a pair or triple | Two indices moving inward | the two pointers chapter |
| Linked list, cycle, middle | Two speeds on one sequence | the fast and slow pointers chapter |
| Longest or shortest stretch with a property | A window with two edges | the sliding window chapter |
| Ranges, meetings, bookings | Sort by start, sweep | the intervals chapter |
| Running median, k largest, merge sorted lists | Heaps | the two heaps, top k and k-way merge chapters |
| Sorted data or a yes-or-no check that flips once | Binary search | the binary search chapter |
| All subsets, orders, valid placements | Choose, explore, undo | the subsets and backtracking chapters |
| Fewest, cheapest, count the ways | A table of subproblems | the dynamic programming chapter |
| Count subarrays with a given sum | Running totals |
A six-week plan
The plan assumes about an hour on weekdays and two hours at the weekend. Each week has a theme, the reading time of its chapters, a count of problems and a review step. Reviewing matters more than volume: re-solve last week's hardest problem from a blank file.
| Week | Chapters | Reading | Problems | Review |
|---|---|---|---|---|
| 1 | Two pointers, fast and slow pointers, sliding windows, intervals, in-place linked lists | 2 h 31 min | 10 | Re-solve two without notes |
| 2 | Heaps, k-way merge, top k, binary search, subsets | 2 h 49 min | 10 | Write the invariant for each binary search; time one problem at 30 minutes |
| 3 | Greedy, backtracking, dynamic programming | 2 h 6 min | 10 | Write state and transition in one line each |
| 4 | Cyclic sort, topological sort, sort and search, matrices, stacks, monotonic stack, prefix sum | 3 h 59 min | 12 | Re-solve two; say the order each stack keeps |
| 5 | Graphs, trees, tries, hash maps, tracking, union-find, custom structures | 4 h 23 min | 12 | Redo two graph problems from a blank file |
| 6 | Bits and maths, range queries, the graph algorithm chapters, mixed practice and the mock chapter |
Check your plan
Before you start, decide your fixed practice time and where you will keep a log. The log needs only four columns: the problem, the pattern you used, the bottleneck of the brute force and whether you needed a hint. After two weeks the log shows which cues you miss.
| Term | Meaning |
|---|---|
| Brute force | The simplest correct solution, usually trying every possibility |
| Bottleneck | The repeated work that makes a solution slow |
| Seed | A number that fixes a random generator so a run can be repeated |
| Stress test | Comparing a fast solution with a brute force on many random small inputs |
| Quadratic | Growth where doubling the input multiplies the work by four |
| Type stripping | Running TypeScript by deleting annotations, with no type check |
A problem asks for the fewest steps to reach a goal in a maze. Which row of the cue table fits?
- Fewest steps in a grid or a state graph points at breadth-first search.
A problem asks how many subarrays add up to a given sum. Which row of the cue table fits?
- Count subarrays with a given sum points at running totals, the prefix sum chapter.
Why review a problem after a day, a week and a month?
- Spaced repetition makes you re-derive the idea, which is what you need when the problem is new.