DEV Community

Cathy Lai
Cathy Lai

Posted on AI-assisted

How I Finally Learnt to Solve Coding Interview Questions

So you have an algorithmic coding interview coming up... You know the standard advice: think out loud, talk as you code, and don't worry about optimizing right away. But what does that actually look like in practice? And how do you prepare for it effectively when time is short?

Preparation

Should I start cramming LeetCode problems? Doing that felt like jumping into the deep end, which would only shatter my confidence. An interview won't go well if you feel insecure before it even starts!

Instead, I started with easy, AI-generated exercises and gradually built up the complexity. ChatGPT is great for that. I aimed for 2 to 3 problems a day, depending on the difficulty. This turned out to be a fantastic approach. I could feel myself improving with every problem, learning at a comfortable pace rather than feeling overwhelmed.

With each exercise, I tried to pinpoint the specific friction points that kept me from solving it smoothly:

  • Not fully understanding the problem before writing code
  • Writing too much code in one go without testing
  • Struggling with self-doubt midway through
  • Getting embarrassed when a bug appeared—and figuring out how to recover gracefully

I even recorded myself during a few sessions and watched the footage back to evaluate my pacing, explanations, and overall presence.

Developing a Rhythm

Through this process, I discovered a working rhythm that keeps me grounded:

  • Clarify assumptions: Write down all assumptions upfront.
  • Verify the setup: Create a dummy function first to print a test output and ensure everything is running.
  • Trace the algorithm manually: Walk through the example input step-by-step to identify every variable needed across iterations.
  • Talk through roadblocks: If I get stuck, I state what I'm trying to solve out loud (e.g., "Do I need a flag here? A running total? Is this tracked per group or across all groups?").
  • Validate the logic: Work through the example input again to confirm variables are being set, reset, or accumulated correctly. Keep tracing until the manual steps produce the expected result.
  • Start coding: Only write code once the logic is proven—this prevents getting bogged down in syntax while still problem-solving.
  • Expose your mental model: By this stage, the interviewer has a clear view of your thought process, as the pseudo-code and variable state tracking are already on the screen.
  • Test incrementally: Print debugging statements early and often to monitor key data structures in real time.
  • Embrace simple debugging: Don't hesitate to use simple print statements. Catching a bug early prevents unexpected output later, which can throw off your composure.
  • Stay calm when bugs happen: If unexpected output pops up, treat it like a regular ticket you're fixing during a normal workday. Framing it as everyday work helps keep your nerves in check.

How About You?

If you are also preparing for interviews, hope these help! What are your tips? Please comment and share :)

Top comments (0)