Skip to content

Learn by poking · 8 interactive labs

Labs: play with the idea before you build it

Each lab is a small working model of one concept from the plan. Move a slider, break something, then answer the interview question it prepares you for. Two minutes each, phone-friendly, no setup.

0 of 8 explored

Big-O, felt not memorised

See why a set beats a list, and what doubling the input really costs.

Used in Week 5 onwards
1,024

Steps needed (bar length is logarithmic)

O(1)x in my_set1
O(log n)binary search10
O(n)x in my_list1.0k
O(n log n)sorted(xs)10.2k
O(n²)two nested loops1.0M

Doubling n adds one step to O(log n), doubles O(n) and quadruples O(n²). That is why interviewers ask for the Big-O of every solution – write it in dsa/progress.csv after each problem.

Race: list scan vs set lookup

List: checks so far

–

looks at every item in turn

Set: checks

–

hashes straight to the slot

This is problem #1, Contains Duplicate: swap the list for a set and an O(n²) answer becomes O(n). The price is extra memory for the set.

Try this

  1. 1Set n to 1,024, then 2,048. Which bars barely move?
  2. 2Run the race five times. The list’s cost depends on luck; the set’s never does.
  3. 3Say the Big-O of problem #1 (Contains Duplicate) aloud, with and without a set.

Interviewers ask

“Why is x in my_list slower than x in my_set?”

Practise it as a flashcard