How to Approach Coding Problems Under Pressure
The coding interview is the moment many candidates dread most. Not because they don’t know how to code, but because the combination of time pressure, being watched, and high stakes can freeze even experienced engineers.
Here’s a repeatable, proven framework for approaching technical problems in interviews — used by engineers at top product companies.
Step 1 — Understand Before You Code
This sounds obvious, but most candidates start coding the moment the question is asked. Don’t. Spend the first 2–3 minutes doing this instead:
- Restate the problem in your own words
- Ask clarifying questions: What are the constraints? What’s the input range? Are there edge cases to consider?
- Write a quick example input/output on paper or the whiteboard
This demonstrates maturity, reduces misunderstandings, and gives you thinking time without appearing stuck.
Step 2 — Think Aloud
Narrate your thinking as you work. This is critical. Even if your first approach is suboptimal, showing your reasoning process is often more valuable than a silent correct solution. Say things like:
- “My first instinct is a brute-force O(n²) approach — let me see if I can do better.”
- “I’m thinking about whether a hash map would reduce the lookup time here.”
- “Let me consider the edge case where the input is empty.”
Step 3 — Start with Brute Force, Then Optimise
Never spend 10 minutes searching for the perfect solution before writing a single line. State the brute-force approach first, confirm it works, then think about optimisation. This demonstrates iterative thinking — exactly how real engineering works.
Step 4 — Write Clean, Commented Code
Even under time pressure, write readable code. Use meaningful variable names. Add a brief comment for non-obvious logic. This signals how you write in production — and it matters.
Step 5 — Test Your Solution
Before saying you’re done, walk through your code manually with your example input. Then test with edge cases:
- Empty input
- Single element
- Very large input
- Negative numbers (if applicable)
- Duplicate values