Do you have a tech interview coming up?
Are you preparing for a Leetcode style interview?
Then you should keep reading to learn more as well as find free resources that can help you ace your next coding interview!
A usual coding interview lasts from about 45 minutes to an hour. While preparing you should aim to be able to solve 2 medium difficulty level problems within 45 minutes or 1 hard difficulty level question with a couple of follow up questions.
This means that within 45 minutes, you should be able to come up with an optimised solution along with written code solutions and time complexities for each problem.
You can time yourself while practicing questions and try to simulate an environment that is as close as to a real world interview.
Participating in Leetcode contests or contests on other competitive programming websites such as HackerEarth, CodeChef etc could help you out in this regard.
Leetcode also has mock assessments that are practice assessments from a collection of real company questions.
Before getting into the solution, always ask for clarifying questions to remove ambiguity from the problem statement.
This would help you think in the right direction.
You don’t want to waste your limited time trying to come up with a solution to a problem that you don’t understand or have misunderstood!
While it may be tempting to jump straight to the optimised solution to save time, it may do more harm than good.
More than the solution itself, the interviewer wants to know about your thought process and how you solve a problem.
You don’t want to look like you’ve seen this problem already.
Always start with a naive solution first and then optimise it.
Do not leave long pauses of silence. While it’s okay to pause and think, make sure to convey your thought process to the interviewer.
If you’re stuck, the interviewer can’t nudge you in the right direction unless they know what you’re thinking.
You would most likely be writing code on a whiteboard, a piece of paper or a text editor with minimal features.
You would also most likely not execute your code.
This means that you should be able to write code without the help of an intelligent editor or compiler.
Practice writing your solutions in a google doc, or a piece of paper, or a whiteboard, whichever you prefer.
Since you don’t have most or any of those fancy features you’re used to like autocomplete, syntax highlighting etc. It’s advisable that you pick a language that you know well. Remember the syntax and commonly used APIs in that language, for example, commonly used packages such as Math or Time.
Python is a great choice since it easy to learn and fast to write up some code with. Also, it has a lot of utility functions that can reduce your coding time. It’s also easy to read and explain.
Treat your interview as if you’re writing code for production. Use good variable names, properly indent your code, do not repeat yourself etc.
You can find style guides for any language for free online. For example, Google and Airbnb have made their coding style guides available for developers to use.
Not only should you optimise your code but also check for those nasty corner cases. Make sure your code is correct and free of bugs. Perform a dry run of your code with sample inputs to catch any bugs.
Thanks for reading. I hope these tips will help you out with your next interview. Good luck!