Interview practice › Solving a problem you have not seen
Tutorial 1 of 4 · Interview practice · Finding the approach · Intermediate Solving a problem you have not seen Six steps that take you from a blank page to working, tested code, shown on one problem from start to end.
6 lessons, the last is a challenge · about 1 h · Python and Java
Before you start You finished the Programming fundamentals path: you can write a function with a loop inside it, in Python or in Java.
You finished "Hash maps": you can store a value under a key, look a key up, and say why a lookup takes about one step on average.
What you’ll be able to do 1 Restate a problem you have not seen in your own words, ask the questions that settle what it means, and work its smallest example by hand. 2 Write the slow, obvious answer first, count how many pairs it checks, and say its cost as O(n²) in plain words. 3 Find the question a slow answer keeps repeating, name the tool that answers it fast, and write the faster code with its cost in time and in extra memory. 4 Test an answer on its edge cases (empty, one item, repeated and negative numbers, no answer) and against the slow answer before saying it is done. Lessons 1 A blank page and a plan Name the six steps, restate two sum and ask four questions about it, and work its smallest example by hand. 10 min, up next 2 The slow answer first Write the brute force for two sum, count the pairs it checks, and say why it is worth writing. 11 min 3 What makes it slow, and the cue Find the question the inner loop repeats, and plan one pass with a hash map from value to position. 11 min 4 Write it, then count again Write the hash-map answer, do a dry run of it, and say its cost in time and memory. 10 min 5 Test the edges before you say done Test the answer on six edge cases and against the brute force. 9 min 6 Final challenge: contains a duplicate Final challenge · Take a fresh problem through the six steps, from restating it to testing its edges. 9 min Next in this path Next: 2 · Which tool for which problem · 6 lessons · 1 h 10 min
Learn the words in a problem that point to a hash map, a window, a stack, a heap or a graph search.
Playground Try the same model with your own values. No checks, nothing recorded.
Open the playground