How to Ace your Next Data Structures and Algorithms Interview?

This article is contributed by Bharat Khanna, Co-founder of Programming Pathshala, who has previously worked at Tower Research Capital as SDE-II.

Lets begin with the preparation!

There is no substitute for preparation. Make sure that you have prepared for different variations of commonly asked data structures and algorithms in interviews like stacks, linked lists, trees, dynamic programming, etc.

Make sure you introduce yourself well.

Introduction is very important for making the first impression on the interviewer. Make sure your introduction is crisp and precise and it definitely mentions your interest in data structures and algorithms. This will prompt the interviewer to majorly focus on this area during the interview.

Discuss strategy first

It is not a good idea to be quiet for a very long time during the interview and then suddenly start typing the code out. The interviewer would not be able to understand your idea and thought process behind that particular implementation.

Make use of hints given by the interviewer

Let’s say you are suggesting a solution which uses Two Pointers technique and the interviewer hints to think about the other thought which you mentioned earlier that involved the use of Binary Search. Then, maybe he/she is looking for a Binary Search based solution.

Discuss Time and Space Complexities

The only way to compare multiple approaches in a Data Structures and Algorithms interview is based on time and space using Big-O notation for measuring time and space complexity.Make sure you have thorough ideas around these estimations and you mention them for every approach you discuss with the interviewer.

Write Clean Code

Many people take the coding part of the interview as the part where they have to deliver very quickly and move on to the next question. But, remember, this is not a coding test or a competitive programming contest where the one who codes first will win. This is an interview where more than speed, it is important that your code is easily understandable to the interviewer.

Handle corner cases well

Another important mistake that people make while writing codes related to Data Structures and Algorithms is that they miss out corner cases like Linked List being empty, Binary Tree not having one of the two children, an Array having negative elements etc. It is very important while preparing to make out a list of common edge cases that you generally miss.

Dry Run the Code on Initial Given Test Case

One last but important step in an interview is to actually dry run your piece of code on the given input so that the interviewer gets the perfect idea of how your logic is working with the help of examples. Wherever in your code, you have multiple code branches, make sure to give him an idea as to which cases will end up in those branches.

We are working to democratise access to Tech Education. We help students learn coding and be confident about themselves.