It is said that getting interviewed for a Coding job role is scary and exhausting. The coding interview test is surely a grueling process that has a lot of back and forth while being tested on your coding skills.
How do I prepare for a coding interview?
The best way to sail through this interview process is to have a few things in mind.
- Game plan
- Communication
- Testing
- Rechecking
- Asking for help
Sounds vague, right? Don’t worry, let’s dive deeper into these 5 points that we’ll present as tips.
How to crack coding interview?
Tip 1- Have a good game plan
Before you begin writing code, you should come up with a plan on how you will tackle the problems that arise later. Spending around 5-20 minutes for this is highly recommended.
A good game plan involves drawing diagrams and doing test examples. For instance, while getting a recursion problem, it is best to draw a tree to identify the different states that you will be visiting and the order of states that you will be visiting.
More importantly, drawing such trees highlights every logic you may need to perform, such as backtracking. Creating a game plan has many advantages. During the test, the interviewer can tell you if you are going in the wrong direction. And if that is the case, then you saved yourself from wasting time on writing the wrong code!
It is also easier to decipher what data variables and structures will be required to solve the problem. If your plan does not work it is fine to reevaluate it. You do not need to define the most efficient way to tackle the problem at the beginning.
It is better to have a working code than a broken code. And this is a common problem faced by many candidates. Once your game plan is implemented, you can refine your approach for optimum results.
Tip 2- Communication is Key
Since you are thinking on your own and the interviewer does not know what is going on in your head, you need to communicate your thought process effectively. This is an important soft skill that will help you focus while the interviewer will be evaluating your approach and problem solving skills.
So when is the right time to communicate?
- While coming up with a game plan.
- When figuring that there are several approaches to solving the problem, and identifying which approach is the most efficient one.
- While detecting a bug in your code.
- When stepping through your final code with a test case to validate the correctness.
Tip 3- Testing your code
The best way to end your test is while writing the final line of codes. It is rewarding and you feel accomplished for solving the test. But this is not the end of it. Do not tell your interviewer that you have finished with the code, without actually validating it by running tests. That will be a bad move.
You do not want the interviewer to point out bugs that you overlooked and mention them in the feedback review. Not testing your code after writing it, is like breaking the most fundamental rules of coding.
No one writes perfect codes on their first try. It is always best to validate your code with at least 2 tests, in order to gain and maintain the trust of your interviewer. Therefore always make sure to test and communicate your code throughout the process.
Tip 4- Recheck given input
Before you begin coding, you need to think about the various forms of your input. This will make it easier for you to choose the game plan you will use.
You can ask questions like:
- Is it a doubly linked list or a singularly linked list?
- Is my array sorted or unsorted?
- Will my array contain negative numbers?
- Can my input be null?
For example, let’s assume that the task at hand is to find a target number in an array. If the interviewer confirms the array is sorted, then you can do a binary search, which has a runtime of O(log N).
However, if the interviewer says the array is unsorted, then you have to do a linear search, which has a runtime of O(N). The nature of the input can change the approach to solving the problem.
Tip 5- Ask for help, but not too often
While attempting the test, there may be instances where you have no clue about what you need to do. It is alright to ask for guidance from the interviewer. Even though the interviewer will make sure of this, you do not want them to give away the solution.
You do want a slight nudge towards the right direction. If you are able to come up with an answer in 1-2 hints, you will still get positive feedback. This will showcase that you are an independent thinker under right guidance.
Do remember, not to frequently ask for help. This might show that you are incapable of solving a problem. Asking for help not more than 2 times is the safest option or else you might lower your chances of getting hired.
If you think these tips have helped you, check out more blogs like this, right here.