February 9 2026
Thinking Before You Code in Interviews
A repeatable way to avoid writing the wrong solution too early in coding interviews.
Andrews Ribeiro
Founder & Engineer
4 min Intermediate Thinking
Track
Senior Full Stack Interview Trail
Step 5 / 14
The problem
Many people lose points in interviews before they write the first line.
They hear a familiar keyword, recognize a known pattern, and rush into implementation.
It looks like speed.
Most of the time, it is just anxiety wearing the clothes of confidence.
The risk is simple:
you can solve the wrong problem very well.
This shows up in:
- coding interviews
- system design interviews
- real work discussions
The context changes.
The mental mistake is the same: building too early.
Mental model
Thinking before you code is not wasting time.
It is reducing the chance of investing effort in the wrong direction.
A useful model fits in four steps:
- restate the problem in your own words
- confirm the constraints and edge cases
- propose the simplest baseline that works
- optimize only when it is clear why the baseline is not enough
If you want the short version:
First make sure you are solving the right thing. Then improve the right thing.
Breaking it down
Reframe the problem
Before you think about algorithms, repeat the problem back in your own words.
That does two things:
- it surfaces misunderstandings early
- it shows that you know how to reduce ambiguity
Close the constraints that change the answer
Not every interview needs a long interrogation.
But some constraints change everything:
- does original order matter?
- do I need to preserve the index?
- can I use extra memory?
- what input size are we assuming?
Two or three good constraints are usually enough.
Ten questions in a row just turns framing into noise.
If you ignore this too early, your chance of picking the wrong technique goes up fast.
State the smallest correct solution
The baseline is the smallest correct solution you can explain clearly.
It matters because it:
- anchors correctness
- reveals the real bottleneck
- gives context for the next optimization
Optimize for a reason, not by reflex
The jump from baseline to a better version needs a clear reason.
Examples:
O(N^2)is already too expensive- I need a single pass
- I need to preserve the original structure
- I need faster response under higher volume
Without that reason, the answer becomes a bag of tricks.
Simple example
Suppose the prompt is:
Find the first repeated number in a large array.
A rushed answer is to open the editor and type Hash Set immediately.
A better answer sounds like this:
Let me confirm the goal first: we want the first value that appears twice in reading order, right? The simplest baseline is comparing each element with the ones after it using two loops. It is easy to validate, but it costs
O(N^2). If the array is actually large, I would trade memory for speed and use aHash Setto detect repetition inO(N).
In a few sentences, you showed:
- understanding of the prompt
- a baseline
- the cost of that baseline
- the reason for the pivot
That is usually enough to make the interviewer relax, because they can see where you are going.
The same reasoning works in system design too.
Common mistakes
- Jumping to the optimized algorithm before validating the problem.
- Staying quiet because you want to look fast.
- Ignoring edge cases because you want to get to the “interesting part.”
- Treating the baseline like wasted time.
- Spending so long framing the problem that you run out of time to execute.
How a senior thinks
People with more experience rarely look like the fastest person in the first minute.
They look like the most controlled.
Their reasoning usually sounds like this:
I want to make sure I am solving the right thing first. Then I will show the smallest correct version. If that version does not scale, I will improve it knowing exactly what I am trading.
That posture is strong for two reasons:
- it reduces rework
- it signals maturity
What the interviewer wants to see
When you think before you code, the interviewer sees more than technique.
They see:
- your ability to reduce ambiguity
- your judgment around baseline versus optimization
- your clarity when explaining trade-offs
- your discipline under pressure
In interviews, the right solution matters a lot. But the way you get there tells the interviewer how much they can trust you.
Mature candidates do not rush to look fast. They move with more control so they make fewer wrong turns.
Quick summary
What to keep in your head
- Thinking before you code is not stalling. It reduces the chance of spending time in the wrong direction.
- A simple baseline comes before optimization because it anchors correctness and makes the trade-off visible.
- In interviews, mature candidates usually look less rushed and more in control.
- How you frame the problem matters almost as much as the implementation.
Practice checklist
Use this when you answer
- Can I restate the problem in my own words before I start?
- Can I confirm constraints and edge cases without turning it into noise?
- Can I propose a short baseline before the optimized solution?
- Can I explain why the baseline stops being enough when I pivot?
You finished this article
Part of the track: Senior Full Stack Interview Trail (5/14)
Share this page
Copy the link manually from the field below.