Codele / Algorithms
How to attack a new problem
A new problem can feel like a wall. A short, repeatable method breaks it into steps you already know how to do.
- Do not start with code. Start by saying the problem in your own words.
- Work a tiny example by hand. If you cannot solve it by hand, code will not help yet.
- Ask which idea it looks like: search, sort first, two pointers, sliding window, graph walk, remember answers or try and undo.
- Write the steps in plain words, then turn each line into code.
- Finally test the edges: empty, one item, all the same. Most bugs hide there.
Loading the playable lesson…