Completed
Available
Locked · open anytime

Level 3: Interview Algorithms Exercises

Level 3 covers the techniques behind the hardest common interview questions, each attached to a real job: pick the best-paid shifts, give change with the fewest coins, suggest "did you mean…?", split a hashtag into words, find the cheapest delivery route, order the steps of a build.

Most tests here include an input where the obvious answer explodes: plain recursion that recomputes the same subproblem millions of times, a quadratic scan. The step counter stops those at once and shows "too slow", and a small tricky input catches a greedy choice that looks right but isn't, so you see why memoization, tables and heaps exist. The Autocomplete project answers thousands of prefix queries with one sort and binary search.

The 10 exercises in this level

  1. 1 Dynamic Programming: Best Shifts Most pay, never two days in a row Find the best-paid set of shifts with no two days in a row by building on answers to smaller problems, where greedy picks and plain recursion fail. Start here — no prerequisites
  2. 2 Coin Change The fewest coins for a cash register Give change with the fewest coins by building the answer for every amount from zero up, where always taking the biggest coin goes wrong. Recommended first: Dynamic Programming: Best Shifts
  3. 3 Word Break Split a hashtag into dictionary words Check whether a hashtag splits into dictionary words by recording which prefixes split cleanly, where grabbing the longest matching word fails. Recommended first: Coin Change
  4. 4 Edit Distance "Did you mean…?" for a search box Count the fewest inserts, deletes and replacements between two words with a table of smaller answers, the idea behind "did you mean…?" suggestions. Recommended first: Dynamic Programming: Best Shifts
  5. 5 Longest Increasing Subsequence The longest price rise, in O(n log n) Find the longest strictly rising sequence of prices, skipping any in between, in O(n log n) with a list of best tails and binary search. Recommended first: Dynamic Programming: Best Shifts
  6. 6 Backtracking: Exact Budget Every basket that costs exactly the budget List every set of items that costs exactly the budget by choosing, exploring and undoing, and stop a branch as soon as it costs too much. Start here — no prerequisites
  7. 7 Topological Sort A build order that respects every rule Order the steps of a build so every step comes after the ones it needs, by counting unmet prerequisites, and report a cycle instead of looping forever. Start here — no prerequisites
  8. 8 Dijkstra's Shortest Path The cheapest delivery route Find the cheapest delivery route on a road map with Dijkstra's algorithm and a heap, where counting roads instead of costs picks the wrong route. Recommended first: Topological Sort
  9. 9 Union-Find Count networks as cables are plugged in Count how many separate networks remain as each cable is plugged in, with union-find and short parent chains so every lookup stays fast. Recommended first: Topological Sort
  10. 10 Project: Autocomplete Instant suggestions for a search box Suggest words as someone types: sort the dictionary once, then answer each prefix with binary search instead of scanning every word. Recommended first: Longest Increasing Subsequence

Frequently asked questions

Is Level 3 too hard if I'm new to algorithms?
Do Levels 1 and 2 first. Level 3 builds on hash maps, heaps, queues and binary search, and each lesson still explains the one idea the exercise needs in a few lines.
How do I recognise a dynamic programming problem?
When the answer for a big input can be built from answers for smaller inputs, and a plain recursive solution calls the same arguments again and again. Store each answer once, in a table or a cache, and the time drops from exponential to polynomial.
Why does greedy fail on coin change and word break?
Taking the locally best choice (the biggest coin, the longest word) can block the best overall answer. Dynamic programming tries every choice but reuses results, so it stays fast and correct.
Which of these come up most in interviews?
Dynamic programming, graph searches (BFS, Dijkstra, topological sort) and backtracking appear constantly. Union-find and the n log n longest increasing subsequence are less common but separate strong candidates.