/Projects
Coding round · 15 patterns · 45 worked problems · 9 mobile components

Crack the coding round with patterns.

Fifteen patterns cover most interview problems. Learn the signals, memorise a template, and spend the interview on the twist.

The method

Six steps, every round

about 30 minutes
1

Clarify

Restate the problem. Ask about input size, duplicates, negatives, empty input, and what to return.

2 min
2

Examples

Work one normal and one edge example by hand. It catches misreads before they cost you.

3 min
3

Brute force

Say the obvious solution and its complexity. It proves you understand the problem and gives a fallback.

2 min
4

Optimise

Match the signals to a pattern. Name the bottleneck and the data structure that removes it.

5 min
5

Code

Write clean code with good names. Talk while you type. Leave helper details for later if needed.

15 min
6

Test

Run your examples line by line, then edge cases. Fix bugs calmly and state the final complexity.

5 min
Patterns

Learn the fifteen

01

Two pointers

Walk inwards from both ends of a sorted sequence.

Sorted array or stringFind a pair or triplet with a target sum
3 worked problems
02

Sliding window

Grow the right edge, shrink the left edge while invalid.

Contiguous subarray or substringLongest or shortest window with a property
3 worked problems
03

Fast and slow pointers

One pointer moves twice as fast; they meet in a cycle.

Linked list cyclesMiddle of a list
3 worked problems
04

Binary search

Halve the search space, including the answer space.

Sorted or rotated array'Minimum X such that…' or 'maximum X such that…'
3 worked problems
05

Prefix sums and hashing

Remember what you have seen to answer in O(1).

Two Sum style complement lookupsCount subarrays with sum K
3 worked problems
06

Monotonic stack

Keep a stack in sorted order to find the next greater or smaller.

Next greater / smaller elementDays until a warmer temperature
3 worked problems
07

Heap / top-K

Keep the best K so far in a size-K heap.

Kth largest or smallestTop K frequent
3 worked problems
08

Intervals

Sort by start, then sweep and merge.

Meetings, bookings, rangesMerge or insert overlapping ranges
3 worked problems
09

BFS and DFS

Explore grids and graphs; BFS gives shortest steps.

Grids of cells, islands, regionsShortest path with equal edge weights
3 worked problems
10

Topological sort

Order tasks so every dependency comes first.

Prerequisites, build order, dependenciesDetect a cycle in a directed graph
3 worked problems
11

Union-find

Merge groups and ask 'same group?' almost instantly.

Connected components that change as edges arriveDetect a redundant edge (cycle in undirected graph)
3 worked problems
12

Backtracking

Choose, explore, un-choose.

All subsets, permutations or combinationsConstraint puzzles (N-Queens, Sudoku)
3 worked problems
13

Dynamic programming

Define the state, write the recurrence, fill the table.

Count the ways / min cost / max valueChoices at each step that affect later steps
3 worked problems
14

Trie

A tree of characters for fast prefix lookups.

Autocomplete or 'starts with'Many words searched in one grid
3 worked problems
15

Greedy

Take the locally best choice, and prove it is safe.

Scheduling by earliest endReach / jump problems
3 worked problems
Mobile machine coding · Kotlin · tested

Build the components apps run on

9 low-level design problems with production-style Kotlin, a line-by-line walkthrough, edge cases, follow-ups and the iOS equivalent.

LRU cacheImage loaderOffline outboxRetrySearch-as-you-typeCursor-based infinite feedResumable multipart uploaderClient-side token bucket rate limiterList diffing for animated UI updates
Open mobile machine coding
Hacks and tricks

The small things that save the round

TypeScript power tools

  • Map + ?? for countsmap.set(k, (map.get(k) ?? 0) + 1) is the one-line frequency map. Map keeps insertion order.
  • Queue = array + head indexq[head++] is O(1). Array.shift() is O(n) and turns BFS quadratic.
  • Write a 25-line MinHeapNo built-in heap: an array, sift-up, sift-down and a comparator. Flip the comparator for a max-heap.
  • sort((a, b) => a - b)The default sort compares numbers as strings: [10, 9, 1].sort() gives [1, 10, 9].
  • Keys by value, not referenceMap and Set compare arrays by reference. Encode cells as r * cols + c, or join into a string.
  • Map for memoisationmemo.has(i) ? memo.get(i)! : compute. Encode multi-part states as one number or string.
  • Infinity and -InfinityClean initial values for min and max comparisons.
  • Explicit stacks for deep DFSJavaScript engines overflow around 10⁴ frames; use a stack for large grids.

Edge cases to test every time

  • Empty inputEmpty list, empty string, n = 0.
  • One elementLoops that assume two elements break here.
  • All the sameDuplicates break uniqueness and pointer logic.
  • Negatives and zeroSliding windows on sums fail with negatives; use prefix sums instead.
  • Already sorted / reversedWorst cases for naive quicksort and some greedy choices.
  • Very large valuesNumbers are exact only up to 2⁵³ − 1; use BigInt for big products or hashes.

Bugs that cost offers

  • Off-by-oneDecide inclusive or exclusive bounds once and write it as a comment.
  • path instead of [...path]Backtracking stores the same array again and again; push a copy.
  • Visited on popMark visited when you enqueue, or BFS revisits nodes many times.
  • Mutating while iteratingIterate over a copy or collect changes first.
  • Missing a key in a Mapmap.get(k) is undefined, and undefined + 1 is NaN. Default with ?? 0.
  • new Array(n).fill([])Every slot shares one array. Use Array.from({ length: n }, () => []).

How to talk through it

  • Narrate decisionsSay why you chose the structure, not just what you are typing.
  • State complexity earlyBefore coding, say the target: 'n is 10⁵ so I need n log n or better'.
  • Name things wellleft/right, seen, best: readable code is scored.
  • Stuck? Shrink itSolve a smaller case or a simpler version aloud; interviewers often hint.
  • Leave stubsIf time is short, write the helper signature and finish the main logic first.
  • Own your bugsFind them by tracing an example. Calm debugging is a strong signal.

AI coding patterns

RRF, DPO, RAGAS, speculative decoding
AI Engineer · coding round