Tips and Tricks for Coding Interviews
Practice, Execute, Reflect!
As a recent graduate from the University of Toronto (U of T) with a HBSc in Computer Science, landing 4 internships (including from a few top FinTech driven companies in Canada) has helped me develop a certain set of skills and knowledge on how to get my-self well equipped for an upcoming interview!
This article is an attempt to share my experience regarding the interview process — including mock interviews, online coding challenges, and step by step process on how to tackle a coding question.
Practice Makes Progress
- Mock Interviews
Coding interviews can be overwhelming for many reasons. Firstly, most (if not all) coding interviews require writing some code with hand, either on paper or whiteboard. This usually is the biggest discomfort that we feel. Secondly, it is very time constrained (maybe 20 mins per question) and so we’re constantly under pressure to find the optimal solution. On top of that, the interviewers are just eyeballing us, in the hopes of an answer will just pop up in our mind!
Although I don’t have a solution on how to mitigate any of these 3 things, I can provide a source which can replicate this scenario — hence the name mock interview. I cannot express enough how helpful these are! All you need to do is find a classmate or a friend, book a room for a few hours which has a board and just write code. Yes that’s right, I said write! Think of it like this — if you have to give a Driving Licence Exam in a car, would you practice with a bicycle? Of course not! Similarly, if you know your interview will require you to write code, then why not practice writing as well (instead of typing).
A key component to this process is having a partner who is well prepared with all types of questions in advance and will give you constructive feedback. I was very fortunate to have friends who were always ready to do mock interviews for hours at once and that really helped me stay prepared for my actual interview as I had a clear plan on what to say, what not to say, what key words to look out for in a problem and some handy tricks for certain types of coding questions.
One thing to keep in mind is to approach the problem as if it is an actual interview, making sure your partner gives minimal (if any) help, not using any other sources, timing your self and most importantly, not giving up so easily! Remember, you don’t always have to find the best solution right away, start with a brute force one and then work your way around it based on the amount of time left. A solution is better than no solution!
I have listed down a few resources down below which can be used to do mock interviews online. They’re a great source during times like Covid-19 where you cannot meet anyone physically.
Code share tool — https://codeshare.io/
Pramp — https://www.pramp.com/#/
2. “Cracking the Coding Interview” (CTCI)
Think of this book as the “one shop stop”. It goes into detail on what to expect in top tech companies and how to prepare your self — including resume tips, interview strategies and what topics to study. Although the code snippets are written in Java, it shouldn’t be too difficult to understand (suggest to practice in the language you will do your interview in).
A common mistake many do is memorize the solutions and expect the same questions to appear on their interview. More important than the solution, understand the approach. Also, don’t start the book a week before your interview and expect to ace it. You will need to start months in advance.
Although it may not be possible to read all 698 pages, I recommend to focus on the following sections:
I. The Interview Process
II. Behind the Scenes (if applicable)
III. Big O (doesn’t hurt to relearn it)
IV. Technical Questions (focus on this chapter)
V. Interview Questions (Chapters 1–4, 7–10)
VI. Hints (read this at least once, it can give you some useful tips and tricks on how to approach certain types of questions)
3. Online Coding Challenges
A great source to rate your preparation level is to use some of the online coding challenge platforms. Nowadays, there are many options containing all sorts of questions including data structures, algorithms, databases and system design. A good habit is to set a certain # of questions you will do per day and post your solutions on your own Github page, this way you can visually track your progress.
A few tools also has questions from popular companies (i.e. top 100 questions from Facebook), although this feature may require a paid subscription.
I have listed a few sources which I usually use to prepare:
Leetcode — https://leetcode.com/
Hackerrank — https://www.hackerrank.com/
AlgoExpert — https://www.algoexpert.io/
Feel free to look at a few of my solutions on my Github repo: https://github.com/tirthsh/Leetcode_Solutions
Tackling The Question
Everyone has their own techniques and their own processes on how to approach and solve a coding problem. But, what’s important is you having one. As you walk into an interview, you should know what to look for in a question, what to write down on the board, and what kind of questions to ask to help you clarify the question further (interviewer will not give you all the details initially, they expect you to ask certain questions).
Following is my process on how I approach a coding question. I note all these steps on the board so the interviewer visually sees my thinking process.
a) Write down the input(s)
b) Write down the output(s)
c) Write down constraint / assumptions we are making (clarify with interviewer)
d) Write down any edge cases
e) Write down a step by step algorithm you are thinking of (pseudocode)
f) Write down time and space complexity
g) Write code
The key is to have a constant conversation with your interviewer, telling them what path you are thinking, what blocker you think may arise with this solution, etc. One simple trick is take a sample example and draw out any diagrams or illustrations and step by step go through how you will solve this example. This will give you more clarity as well.
Day of The Interview
- Confidence!
“Whatever you think that you will be. If you think yourself weak, weak you will be; if you think yourself strong, strong you will be.” — Swami Vivekananda
If you walk into an interview thinking you will not do good, then you have already failed. You should go into the interview with positivity, trusting all the hard work you have put leading up to this step. One small trick that always helped me bring some self-confidence is wearing a suit to the interview. Although to most Software Developer interviews this is an overkill, it’s always better to overdress than under. Not only that, it almost always brings a smile to the interviewer because most technical interviewees don’t dress this formally. It will immediately set the right tone and will give an impression that you are serious about the job.
There will be times when you may be under pressure and/or stressed, but it’s important how you handle your self. One easy way to calm your self down is to ask to drink a glass of water (this way you will relax your body and more importantly, while you’re drinking, you can think of some possible solutions for the place you’re blocked on — for some reason it always works for me). If you are completely stuck, it is okay to ask for help. Don’t think if you ask, they will automatically reject you. As long as you have mapped out your ideas and have shown that you really tried, the interviewer will definitely be willing to give you a hand!
2. Post Interview
Whether your experience went well or not, you should do the following after your interview:
Email a “Thank You” Letter to the Manager / HR within 24 hours after the interview. This will show your humbleness and appreciation for the opportunity.
Note down all the questions that were asked. This is a great way to prepare for the next interview.
Self-reflect. Try solving questions you couldn’t solve during the interview, or improve your solution to the one you could solve.
Keep applying, don’t just wait for the offer! A reply can take up to days or weeks at times. Never put all your eggs in one basket!
Common Mistakes
- We keep our thoughts to our-selves. That is the worst thing you can do! Believe it or not, the interviewer usually doesn’t care about your final solution, rather they’re interested in the process to the solution. If you keep a conversation going (thinking out loud), it will show the interviewer you can communicate clearly, and they can also jump in if you are heading in the wrong direction or need any clarification.
- We jump (programming) languages. This is very common especially amongst relatively newer interviewees. If you practice with Java, then stick with Java during your actual interview as well! Going back to my Driver Licence Exam example, you don’t want to practice in a Van but give your exam in a Mini-Car. Personally, I recommend languages which are dynamically typed (i.e. Python) — it will save you a lot of time!
- We cram things the night before. A very important, yet usually overlooked, component is, sleep! Trust me, it will be very obvious if you look drowsy and uncoordinated. Try to get at least 8 hours of sleep the night before your interview.
Final Words of Wisdom
It is okay to have a bad interview, we have all been there. But what is worse is if we don’t develop and learn from the experiences. Don’t be afraid to seek help, whether that may be from your classmate, your seniors or your professor — keep your ego out the door!
I wish nothing but the best for you, hope this article has given you some tips on how to tackle a coding interview and hopefully made you more confident going in to your next one.
Please share the article with your friends and peers if you found it useful!
Handy Resources
- Big O Sheet — https://www.bigocheatsheet.com/
- CTCI PDF — https://www.shorturl.at/cwJ13
- Tech Interview Handbook — https://yangshun.github.io/tech-interview-handbook/