Stuck in a coding interview? 5 think-aloud tricks for freshers
Most freshers lose live coding rounds to silence, not to wrong code. These five habits show interviewers how you think, even when you don't know the answer straight away.
Published by Hirastra
Clarify before you code
Don't start typing. Restate the problem in one line and ask 2 to 3 questions about input and edge cases. Interviewers score this, and it saves you from rewriting later.
So I return the indices, right? Can the array be empty? Can there be negatives or duplicates? Roughly how large is n?Say the brute force first, out loud
Explain the simple solution and its complexity before optimising, then offer the faster version. A working slow answer beats a half-written clever one. Always name time and space complexity.
The simple way is two loops, O(n²). With a hash map I can make it O(n). Shall I code that?When stuck, trace a tiny example
Silence is what fails candidates. Write a small input and walk through it aloud; the pattern usually appears. If you still need help, ask for a nudge by naming the options you are weighing.
Let me trace [2,7,11,15], target 9. At 2 I need 7, so I store what I've seen. I'm choosing between sorting and a hash map. Am I on the right track?Dry-run before you say done
Run your own code line by line on one normal case, then on the edge cases. Finding your own bug before the interviewer does earns points. Finish by stating complexity.
Empty input, 1 element, duplicates, negatives, very large n, off-by-oneKnow the round format before the day
Some companies run live coding on a shared editor, others start with a timed online test. Check how the company hires on Hirastra's companies page, then practise that exact format in a plain editor without autocomplete.
hirastra.com/companies
Skip the searching: today's verified openings are posted three times a day with official apply links, and you can check your resume against any of them with the free ATS checker.