How to Ace a Technical Coding Interview

Some tips and tricks I’ve discovered after 100+ technical interviews

Christopher Luc
uWaterloo Voice
3 min readSep 26, 2016

--

Photo by ThisisEngineering RAEng on Unsplash

I’ve struggled a lot with technical interviews before; but over time and with a lot of practice, I’ve discovered a few tips and tricks that improved my results significantly. When I started doing technical interview, I failed almost every single one of them - fast forward two years and now I’ve received offers from Snapchat, Square, Twitter, Yelp and more.

During the Interview

I’ll break down a typical interview into different portions and layout my tips and tricks in respect to this breakdown. Most interviews proceed in the following fashion: problem statement and clarifications, discussing potential solutions, coding implementation, verifying correctness, and a final discussion.

  1. Take a deep breath and stay relaxed. Interviewers are usually rooting for you and looking for a reason to give you a pass. Once you begin to stress, it will degrade your ability to think and code.
  2. Listen carefully to the problem. Make sure you understand it completely.
  3. Ask many questions and clarify any assumptions. Sometimes clarifying simple assumptions make a seemingly difficult problem a lot easier. I’ve failed a lot of interviews because I was missing a lot of details.
  4. Think out loud - all the time. This means saying everything that comes to your head. What you say when you’re thinking out loud doesn’t have to make complete sense. It gives the interviewer a rough idea of what you’re thinking about and how you think. In contrast, communicate clearly when you’re trying to convey something important to the interviewer, like a realization or explaining a concept. Constantly communicating is super important.
  5. Come up with a naive solution first; don’t optimize too early. The naive solution is usually the first solution that you think of.
  6. Optimize your solution for better time and space complexity - if the interviewer asks you to optimize. Brainstorm ideas and do some lateral and linear thinking on top of your ideas. This is the hardest part of the interview, in my opinion.
  7. Prove and communicate the correctness and run time of your solutions. Assess tradeoffs of different solutions and choose the best one based off of these tradeoffs.
  8. Be confident. Be confident with your claims and back them up with logic or data.
  9. Code your solution(s). The interviewer is now testing your implementation skills. Again, speak out loud while you code, so it’s easy for the interviewer to follow.
  10. Prove your code is correct. You can run through the code line by line with a few simple examples. You can even create unit tests if your code is runnable.
  11. Think about edge cases. These are the potential inputs that can break your code. Determine if your code handles these edge cases, if not suggest or code the changes to handle these cases.
  12. Reflect on changes and improvements. Given more time, what optimizations and changes would you make to improve readability and efficiency? Do you still think your current solution is the best solution?

Preparing for the Interview

Practice

Practice. Practice. Practice. I start practicing up to two weeks in advance. When I have time, I’ll be practicing coding problems on HackerRank, TopCoder or LeetCode. There are a lot of good resources out there and most of it is useful.

I like these websites because they have a lot of challenges, of varying difficulty, that are similar to technical interviews. HackerRank is nice because it compiles and runs your code against a set of small and large test cases to verify an optimal run time and correctness.

Practice allows you to discover novel solutions and techniques that can be applied to various problems in technical interviews. It’s like how you solve homework problems to prepare for a test. For problems you’re not sure about, you can practice and compare solutions with your peers. Also, practicing a large variety of problems is useful because there are so many topics in CS that can be covered in interviews.

Learn and Relearn the Fundamentals

Make sure you brush up on the basic data structures and algorithms. Review how data structures are implemented and their run times for different operations. Review the different algorithms and they’re tradeoffs for certain problems. Common data structures for interviews are trees, arrays, maps, sets, stacks, queues and graphs. Common types of algorithms used in interviews are dynamic programming, recursion, divide and conquer and graphs.

--

--

Christopher Luc
uWaterloo Voice

Software Engineer at WhatsApp. I write about tech, finance and personal growth.