teacher
Sign in

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.

20 minCF 800–10003 interactive10 problems

The routine

Strong solvers do not wait for inspiration. They run the same steps every time.

  1. Read the statement twice. Underline the input format, the output format and every constraint.
  2. Work the examples by hand. Do not just compare outputs. Ask why that answer is correct.
  3. Write a brute force in your head or on paper: the slowest correct approach.
  4. Check the constraints. Is the brute force fast enough? If yes, code it.
  5. Look for a pattern or something that stays true, then speed up.
  6. Convince yourself the idea is correct before typing.
  7. Code it, then test edge cases.
1 of 7