How to Solve Any Problem
A step by step method.
In a coding interview, the interviewer cares as much about how you think as whether you finish. A calm, repeatable method makes a huge difference. Here's one that works.

- How you think matters
- A calm method
- One that works
Five steps
First, understand the problem. Repeat it back, and ask about edge cases, like empty input or duplicates. Second, work through a small example by hand. Third, describe a brute force solution, and its Big O. Fourth, improve it, using the clues and tools you know. Fifth, write the code, then test it out loud with your example and the edge cases.
- Understandask questions
- Examplesolve one by hand
- Brute forcesay its Big O
- Improveuse the right tool
- Code and testedge cases too

Habits that impress
Think out loud, so the interviewer can follow you, and help you. Name your variables clearly. Mention the time and space complexity without being asked. And if you're stuck, say what you're trying. Silence is the one thing that really hurts.
| key | value |
|---|---|
| Think aloud | show your reasoning |
| Clear names | left, right, seen |
| State Big O | time and space |
| Never go silent | say what you're trying |
Summary
Understand, try an example, brute force, improve, then code and test. Next, we'll use that method on real interview problems, starting with water containers.
Key takeaways- Understand and ask
- Brute force first
- Test out loud