How to Think About a Problem
A repeatable routine for reading a statement, finding a brute force, spotting the pattern and checking your answer before you submit.
The routine
Strong solvers do not wait for inspiration. They run the same steps every time.
- Read the statement twice. Underline the input format, the output format and every constraint.
- Work the examples by hand. Do not just compare outputs. Ask why that answer is correct.
- Write a brute force in your head or on paper: the slowest correct approach.
- Check the constraints. Is the brute force fast enough? If yes, code it.
- Look for a pattern or something that stays true, then speed up.
- Convince yourself the idea is correct before typing.
- Code it, then test edge cases.
1 of 7