Make sure you correctly understand the question before you even try and implement it.
Understanding the input and output format can help visualize the problem better. It can also help in coming up with a solution to the problem.
Running through an example clarifies with the interviewer that you have understood the problem well. It also gives you an example to test your code once you've completed coding your solution.
This helps the interviewer know what you're thinking and also correct you if you're on the wrong track. If you're stuck you can think of the various Data Structures that could help solve the problem and move ahead from there.
If your solution is not the most optimal one, your interviewer will hint at there being a more optimal approach. You must discuss the time and space complexity of your solution.
Remember to TALK ALOUD while coding. Your interviewer can't read your mind. Hence, it is important to keep explaining what you're doing to make sure the interview understands your code as well.
Once you have coded your solution, go through it entirely to make sure your code does not have any bugs. Use the example test case in (3) and run that through your code. You must also test your code with certain edge cases, to make sure it won't break.
Next time you prepare for an interview, follow this 7 step process and it will improve your chances of landing that dream job of yours. 🚀
If you liked this article and would like to read similar work, be sure to follow me on Twitter where I’ll post updates about publishing my latest articles.
Please feel free to share your thoughts on this article in the comments section. If you guys have any suggestions regarding this article or on any other interview tips, I would love to know.