Coding interview tips

By Aaron Cao · Updated

Clarify the problem and constraints before coding, narrate your approach out loud, reach a working solution before optimizing, test with edge cases, and state time and space complexity. Interviewers score how you reason and communicate, not only whether your final code runs.

Before you write code: clarify, then plan

If your instinct under pressure is to start typing immediately, that instinct is what this section fixes. The strongest candidates spend the first few minutes not coding at all, and interviewers notice.

Begin by restating the problem in your own words and confirming it with the interviewer. Ask about constraints: input size, value ranges, whether the input is sorted, how to handle empty or malformed input. Then name your intended approach and its complexity before you write anything. This short planning step catches misunderstandings early and shows structured thinking, which is a large part of the score.

While you code: think out loud and build in steps

Silence is the most common way a strong solver looks weak. Keep a running commentary of what you are writing and why, so the interviewer can follow your logic and nudge you if you drift.

Reach a correct answer before a clever one. A simple brute-force solution that runs is worth more than an elegant idea that never compiles, and you can optimize once something works. Write in small, testable pieces, use clear variable names, and if you get stuck, say what you are considering rather than going quiet. Interviewers frequently give hints, but only when they can hear where you are.

After it runs: test, edge cases, and complexity

A solution is not finished when it compiles; it is finished when you have tried to break it. Walk through your code with a normal input, then deliberately hostile ones: empty input, a single element, duplicates, negative numbers, the largest case the constraints allow.

Consider a frontend engineer interviewing for a mid-level role who writes a working two-pointer solution, then, unprompted, traces an empty array and a single-element array through it and states the runtime as O(n). That final minute of self-testing and complexity analysis often separates a hire from a maybe, because it signals the engineer will catch their own bugs on the job. Say the time and space complexity out loud even if you are not asked.

Turning tips into habits before the real round

Reading tips is easy; performing them while nervous is not. The fix is rehearsal under conditions close to the real thing: a timer running, your solution spoken aloud, and no pausing to look things up. After each practice problem, review not just whether you solved it but whether you clarified, narrated, and tested, since those are the habits being graded.

Timed spoken rounds against an AI interviewer are one way to build the reflex; you can run them on the mock interview tool. One caution worth repeating: real coding rounds are often on a watched shared editor or recorded, so no live assistant is safe during them, and the goal of practice is to not need one. More answers on coding rounds are in the interview types topic hub, and practice guidance is in the mock interviews topic hub.

FAQ

What is the most important coding interview tip?

Clarify before you code and narrate while you do. Interviewers score your reasoning and communication, so a well-explained approach beats a silent correct answer. Confirm the problem and constraints first, then think out loud.

Should I write the optimal solution first?

No. Reach any correct solution first, even brute force, then optimize it in front of the interviewer. A working simple answer scores better than an elegant idea that never runs.

How do I handle getting stuck?

Say what you are considering out loud instead of going quiet. Interviewers often give hints, but only when they can hear your thinking. Restate the problem and try a smaller example to unblock yourself.

Do I need to state time and space complexity?

Yes, even if unprompted. Analyzing Big-O shows you understand trade-offs, which interviewers weigh heavily. State the complexity of your approach before and after you code it.

Related questions

← More on Interview Types