Key to nailing the interviews

For the longest time, I thought that passing an interview requires you to successfully solve a problem. The solution you provide should be optimal and you need to code it.
My University hosted a Job Fair for Summer Internships, where despite my seniors telling me that Job Fairs are a waste of time, I decided to to go anyways. I visisted the Oath booth, was greeted by an inquiring face which I liked. Unlike other companies, they person took their time to go through my Resume, asked questions about my projects. I made sure to email that person later during the day to thank him for his diligence. I was later contacted by the same person to schedule telephonic interview rounds. Much to my delight, I scheduled those rounds in the following week. I know I should I have reserved atleast 1 week to practice, but this was my first time. Anyhow, I was asked the Peak Value in an Array problem. I gave a linear time solution, then gave a O(log(n)) solution. The second was a Single Runway Airport problem. It was a complicated problem, so I won't go into details. The interviewer was happy with my solutions and he scheduled me for another round. Mind you that I was a novice at LeetCode that time, and had hardly done like 3-4 problems. Later during the day, I googled the solution for the Peak Value problem and found the solution in LeetCode and that's when I realized how important it is to practice different kinds of problems.
Coming to the second round of interview, which in my opinion was a disaster. The problem was to find the Lowest Common Ancestor of two nodes in a Binary Tree. The root was not given, just the two nodes with their parent references. I have problems with Tree algorithms. The first solution I gave was to use a Set. Use one node to traverse all the way to the root and add all of it's ancestors to the set. Then, use the second node and start traversing to the root, but if any of the ancestor is in the set, we found our LCA. The interviewer wanted me to find a constant space solution. We had 30 minutes left, and I kept hacking at the problem until the last 15 minutes where it finally hit me. Find the height of the two nodes, bring them to the same level and then start iterating until both nodes are equal. But I wasn't able to code it, but just explain it verbally. I was able to answer further questions about the complexity of my algorithm and she liked my thinking process and how I was able to relate my solution to her.
Since then, I have realized that your problem solving techniques, logic and being able to justify your logic matters more than plain coding. I have started solving LeetCode problems, documenting my code and writing comments. You can find it here. It is basically a repository of my solutions explaining my logic so if I ever see a similar problem, I can look it up and check how I solved it. I plan to keep it updated with any problems I solve.

P.S.: I forgot to mention that I did end up getting the internship (Summer 2019). Even though I wasn't able to code the solution in the second round, my thinking process and the solution that I came up with along with my sound reasoning was all that the interviewer was looking for.

Comments (2)