Brute Force First: A Coding Interview Strategy That Works

Brute Force First: A Coding Interview Strategy That Works

Many candidates treat brute force like a confession of weakness. Interviewers often treat it like a green flag. A brute-force-first coding interview strategy gets correct structure on the board quickly, proves you understand the problem, and creates a clean runway to optimize—without the freeze that comes from hunting a remembered editorial in silence.

Why brute force first works

Live rounds grade process under time. Optimal-from-second-zero fails when:

Brute force first gives you:

  1. A correct mental model
  2. Visible progress
  3. A baseline complexity to improve
  4. Something to dry-run while you think

Senior signal: “Here’s the clear O(n²). Given n, I’ll move to O(n log n) next.”

Junior signal: silent struggle for an O(n) trick that never lands.

The strategy in five steps

1. Clarify until the goal is crisp

Constraints decide whether brute force is acceptable. Ask bounds on n, value ranges, and edge behavior before you commit.

2. State the brute plan out loud and on the pad

Two lines max:

Brute: for each i, scan remainder / recompute
Correct; time O(n²); space O(1) or O(n) if copying

If you cannot state a correct brute force, you do not understand the problem yet—keep clarifying or walk an example longer.

3. Implement the clear version (or a clear sketch)

Depending on time:

Say which path you are taking.

4. Call the bottleneck explicitly

“The inner scan repeats work. I can precompute / use a map / maintain a window to remove it.”

Name the repeated work. Optimization without a named bottleneck sounds like guessing.

5. Optimize on purpose, then dry-run

Change one thing at a time. After the better version, walk three cases before “done.”

Talk tracks that land well

Permission to start simple:

“I’ll start with a correct brute force so we share the same model, then optimize for the constraints.”

When constraints kill brute force:

“O(n²) won’t fly for n=10^5. I’ll outline brute for correctness, then implement the O(n log n) version.”

When time is nearly up:

“I have a correct O(n²). If we have two minutes I’ll sketch the heap approach and its complexity.”

Partial credit with clear tradeoffs beats a half-typed clever idea.

Patterns where brute → better is the whole interview

FamilyBruteTypical upgrade
Subarray / substringNested scanSliding window / prefix
Top-kSort all each timeHeap / count + sort
Pair sumsNested loopsSort + two pointers / hash
Path existenceDFS retry from scratchBFS / visited set
DuplicatesCompare all pairsSort or hash set

Practice saying the upgrade sentence before you code it.

Mistakes that make “brute first” fail

How this interacts with freeze recovery

If you blank, brute force is often the smallest next step:

  1. Narrate last understanding
  2. Restate goal
  3. “Smallest step: write the O(n²) plan”
  4. Put it on the pad

You are no longer blank. You are executing a strategy interviewers recognize.

Practice plan (one week)

DayFocus
MonMedium: force full brute implement, then upgrade
TueMedium: outline-only brute + full optimal (time-box 8 minutes for outline)
WedSame in company tool (CoderPad / shared doc)
ThuReview bottlenecks catalog (table above)
FriTimed mock: must say a brute→better sentence out loud

Score yourself on whether the brute was correct and whether the bottleneck was named.

Soft tooling note (practice only)

If you want a Chrome side panel beside your question and pad while you rehearse brute→better under a timer with narration, Luna Interview is built for that practice loop. Use it for structured practice and calm under pressure—not as a substitute for knowing the material or for anything that violates interview rules.

FAQ

Will they think I’m junior if I start with brute force?

Not if you call complexity and constraints. They think you’re junior if you only have brute force and cannot discuss improvements—or if you thrash silently for an optimal you cannot explain.

What if the only intended solution is a specific trick?

Outline brute, name why it fails constraints, then move to the intended approach. You still showed understanding. Many interviewers prefer that path to a memorized trick with no model.

Should I always code the full brute?

No. Use judgment. Tiny n → code it. Huge n → outline and upgrade. Always make the choice explicit.

Bottom line

Brute force first is not laziness. It is a coding interview strategy: correct model, visible progress, named bottleneck, intentional optimize, dry-run. Practice saying the sentences until they are boring. Boring tradeoff talk is what strong rounds sound like.