How to Practice and Ace Coding Interviews

Do you still find Leetcode-style algorithmic coding interviews challenging? You are not alone. Algorithmic problems are tricky even for the most seasoned engineers. I won’t debate the merits of such interviews here. The reality is many teams are still using them to determine your coding and algorithm skills. If you are planning to interview soon, you need to prepare for these sessions.

The are 3 key aspects to proper preparation:

  1. Revisit and strengthen the foundations
  2. Practice, practice and practice some more
  3. Mock interviews that replicate the interview settings

Let’s look at each of these in details.

Revisit and strengthen the foundations

A senior engineer with years of experience under her belt may be tempted to jump right into practicing problems. However, the longer it has been since college or your last interview, the rustier you might be in certain areas. You will likely be strong in topics and data structures that you routinely use at work, but there will be other areas of weaknesses. Facing a question during interview thats in an area of  weakness can feel unfair, and takes away your opportunity to really showcase your skills.  So it’s best to find and improve them.

So how do you go about finding your weaknesses?

Start by working on problems across the various topics ie. aim for breadth rather than depth. The goal is to gauge your comfort level with the topics and the problems. Pick a couple of easy to medium problems. Work on each problem slowly. Don’t time yourself yet, just focus on solving the problem and testing your recall.

For any topic where you struggle, hit the books, find a blog post, or a youtube video on it. Set your pride aside and put your beginner hat on to revisit and revise the concepts. Try another set of easy to medium problems again to retest yourself. Repeat until you find yourself improving on the topic.

Practice, practice and practice some more

Most people don’t practice enough. The key to practicing well is to repeat the same set of problems over and over. But wait, what’s the point of solving the same problems you have already solved before? The goal is to grease the groove and improve pattern recognition and time management when answering the question.

Here’s a step-by-step practice protocol that I have used to before:

  1. Pick 5-7 problems for each specific principle or topic. By principle I mean things like divide-and-conquer, DFS, BFS, Graph based etc. Work on these problems on repeat over and over. Yes, after a while the problems become very familiar and you will complete them quickly with each iteration. The repetition will train your ability to recognize the type of problem and the approach to solving them.
  2. Work on new problems (outside the 5-7 problem sets) occasionally to test progress and ability to recognize the approach for optimum solution

As you get better at solving problems quickly, the final step is to test yourself in a mock interview setting.

Mock interviews that replicate the interview settings

Testing yourself in a mock interview setting is important if you don’t want the interview environment to interfere with your ability to perform at a top level. Once you have an interview scheduled, ask the recruiter or hiring manager about the interview setup. Will there be one question or two? Will it be in person on a whiteboard or remote over Zoom? If it’s remote, what screensharing app will they use for the coding portion? Will they build and run the code? etc.

Once you have this intel, craft your mock interview setting exactly to those details. It’s best to have a friend conduct the interview to complete the rehearsal. Time yourself to ensure you are solving problems within schedule.

This is also the stage where you should practice talking out loud as you solve the problem. Interviewers want to hear how you think and some of us prefer to think through problems in silence. Being silent for too long during a problem solving interview can leave too much to the interviewer to assume. So practice talking through your work with your friend during the mock interviews.

Leave a Reply