Wednesday, March 9, 2022

Google interview: Case study

March 9,  2022

Here is the article. 

Experience: 2 years
Position: L3 (Software Engineer)
Location: Bangalore, India
Offer Date: July, 2020

I would like to give huge thanks to Leetcode and the community. Without Leetcode and the community's help, this offer simply would have been less likely.

I was contacted by the Google recruiter around last week of March through Linkedin. I got a call from the recruiter around April first week to begin with the interview process. Since I was completely out of touch, I asked for a month time to prepare for the telephonic interview. However the recruiter gave me 2 weeks of time to prepare for the telephonic round, and told that he will give me 1 month extra time to prepare for the onsite rounds once the telephonic round is cleared.

Preparation for telephonic round
The recruiter shared the bunch of resources and guides to prepare for the coding interviews. Before this, I was very inactive in Leetcode and I used to sporadically participate in the Leetcode's weekly contests. After the call with recruiter, I started prepping more aggresively in Leetcode for the next 2 weeks for my telephonic interview. I solved roughly around 125 problems (25 easy, 80 medium, 20 hard) in the 2 weeks time, covering the most common topics like Trees, Graphs, DP, arrays, binary search, etc.

I have had the access to my friend's premium Leetcode account, where I mostly practiced the Google filtered medium-hard level problems. I also completed all the Google phone interview mock interviews from the premium account. I also managed to solve most of the problems from the featured 'Get well prepared for Google Interview' explore card available in Leetcode premium. I was practicing writing code in Google Doc, which really helped me simulate the real interview process.

Interview Process

Telephonic Interview (45 mins)

The interview was scheduled to happen in the mid week of April, but it got rescheduled twice, firstly the interviewer did not appear, and the second time the interviewer mentioned there was lot of noise in his place, and asked to reschedule the interview. Finally, the interview was scheduled for the last week of April.

The interviewer asked me quite straight forward easy-medium array problem based on the binary search. There were two parts of the problem, the first part being just the straight forward implementation, while the second part requiring the binary search to solve.

I solved both the parts of the problem quickly, along with the dry run of some examples and explanation in around ~30 minutes. Then the interviewer asked me the big O complexity for both the solutions and asked me to think of some test cases. I wrote down around 10 different test scenarios for the problem, along with their expected output. We were still left with roughly around ~5 minutes, I asked him a few questions.

Virtual Onsite Interviews

After about an week, I followed up with my recruiter regarding the feedback of my telephonic round, and the recruiter told me that the feedback is not yet updated in the system and will let me know once the feedback is updated. Almost after a month (around 3rd week of May), I got a call from my recruiter saying that I have cleared the telephonic round and they are heading towards my virtual onsite interviews. He briefed me about the virtual interview process and asked me how much time I would require to prepare, so I asked him for a month time to prepare. The onsite interviews were scheduled for mid week of june. He shared few resources and tips to prepare for the interview.

Preparation for Virtual Onsite Interviews

The preparation for the onsite interviews were almost similar to that of the telephonic round, except that I had more time to prepare and I could solve lot of problems. I started participating actively in the Leetcode's weekly contests and upsolve the problems from the past contests which I had missed. I also started participating in the Leetcode's monthly challenges.

The result of telephonic round took almost a month, so I was prepping during that time as well since the interview had went really well and I was quite sure about moving to onsite. I solved roughly around ~300 problems in 2 months time, which consists roughly around 30 easy, 200 mediums, and 70 hard problems covering most of the important topics like Arrays, graphs, trees, DP, greedy, recursion, binary search etc. Apart from these, I also completed all the Google Onsite Interview mock interviews from my friend's premium account. I completed all the problems from the featured 'Get well prepared for Google Interview' explore card available in Leetcode premium. I use to write the code in Google doc, initially it was tough but after writing a lot of codes in doc, it became cakewalk and and most of them would get a clean AC verdict when copied and pasted to the Leetcode's beautiful editor!

Technical interview 1(45 mins)

The first problem was based on the binary tree, and the difficulty of the problem was Medium. I spent around 5 minutes to understand and rephrase the problem, and after brainstorming the next 5 minutes, I came up with an approach and shared it to the interviewer. He agreed upon the approach, and asked me to code. I spent around 15 minutes (too long) to code the solution. I walked through the code with the sample inputs and started looking for the off-by-one-errors and the other bugs. The code was working fine and the interviewer moved on to the next problem.

The second problem was also based on the binary tree. I quickly came up with the solution in < 5 mins, shared with the interviewer, he agreed and asked me to code. I coded it up in around 10 mins, and walked through some same inputs and it worked! We were left with roughly 5 mins, and I asked a few questions to him related to Google.

The interview ended with the interviewer telling me that I did a good job and wished me good luck for the other interviews.

Technical interview 2(45 mins)

The first problem was a medium problem. I gave him 2-3 approaches to this problem, and he asked me to code the dynamic programming based approach. I quickly coded up the solution, and we were done with this problem within 20 minutes of the interview.

The second problem was about designing and implementing few methods in a class, the difficulty I'd say was medium, and it required the knowledge of heap / priority queue to solve it. I discussed the priority queue based approach with him, he agreed and I quickly coded up the solution. He asked a few questions or follow ups which I was able to answer pretty quickly as well.

We were left with 5 minutes, I asked him a few questions and I could clearly see that the interviewer was really impressed. This was my best round so far, and I heard from my recruiter that I got a very good feedback from the interviewer.

Technical interview 3(45 mins)

The problem was based on the binary tree. I discussed the approach with the interviewer, he agreed and asked me to code it. I quickly coded it up in < 5 mins, and while I was looking for off-by-one-errors, I found a small case which was not handled in the code, I fixed it. Then we walked through the code for a few sample inputs, and it worked. He asked me if there are any optimization areas in the code, I did a few optimizations (case eliminations), although the time complexity would not change. The interviewer said the solution is correct and optimal, and asked me the time complexity. I struggled a bit while answering the time complexity, because it was not quite trivial, eventually with some help from the interviewer, I was able to come up with the correct time complexity of the code.

Since we were left with 25 minutes, I was expecting another question, but the interviewer told that he would be asking few follow ups on the same question. He told that the solution I have provided is the most optimal solution in terms of Algorithmic view, and we can not further optimize it, but if we have to solve this same problem for large scale systems, then we can not afford to have O(N^2) solution, so he asked me to come up with something approximate / heuristic solution which is close to the correct answer and would run in a linear time.

I initially proposed a very basic random approximate solution, which would run in linear time but it was not very accurate. He asked me to optimize the accuracy, I proposed another solution, he asked me to further optimize it, like this way, I gave him around 6-7 different approximate based solutions, after continuous iterations. He finally said that we have reached the accuracy to very good extent, and this should work for most of the scenarios, and we need not optimize it further. We were left with some time, and I asked a few questions to him. The interview ended 5 minutes early.

Technical interview 4(45 mins)

The first problem was based on the binary tree. There is a binary tree root pointer given, we need to check if for every node in the tree, the absolute difference between the sum of all the nodes in the left subtree and the sum of all the nodes in the right subtree satisfies some given condition.

I shared the linear O(n) recursive solution with him, and he agreed with that approach. I coded the solution and we walked through the code for a few sample inputs, and it worked. He also asked a few counter questions related to the code, to which I was able to answer all of them. The interviewer asked if there are some optimizations possible in the code, I did a few obvious optimizations (case eliminations), but that would still not change the time complexity. He agreed and we moved on to the next problem.

The second problem was a medium problem based on strings to check whether the answer exists or not. I did brainstorming for some time, and was able to come up with the linear O(n) solution. I shared my approach with him, and he raised a few counter questions on my approach, but I was able to resolve them by trying out the approach on some examples, he agreed and asked me to code it. I coded up the solution in ~7-8 mins, we walked through few sample inputs, look out for off-by-bit errors, everything was fine.

Next, he asked the follow up for the above problem, that now we also want to return one of the possible answer if the answer exists. I discussed him the linked list based approach to construct one of the possible answers, he agreed. Although, he did not ask me to write a code for it. We were still left with some time, so I asked him a few questions on his recent projects in Google. This was also one of the best rounds I have had so far.

Non technical interview

After a few days, I got a call from my recruiter saying that I have received very good feedbacks from my coding interviews, and the next round is the Googleyness round. He shared some useful docs and guides to prepare for it. I asked for 1 week of time to prepare it as I really wanted to crush it.

Result

After a few days, I got a call from my recruiter saying that I have received above average feedback from my googleyness round, and they are moving ahead for the Hiring Committee round. The recruiter asked for the internal references from the Googler whom I know. I got a really really strong internal reference from my friends who are working at Google. After a few days, I got a call from recruiter saying that the HC has requested for 1 more additional coding interview. The recruiter told me to practice the hard problems, so I took 1 week of time for preparation, and practiced the Googled filtered hard problems from Leetcode. I solved around ~40-50 hard problems in 1 week of time, and revised some of the problems which I solved in the past during the onsite round preparations.

Technical interview 5(45 mins)

The problem was based on the Graph theory. The problem was definitely hard, and it took me quite a while to come up with the most optimal approach. I started with the brute force approach, to check and find every possible candidate answers, and find the optimal one.

After thinking for a while, the optimal solution clicked on my mind, and I shared the approach with the interviewer, he agreed and asked me to code it up. I took around ~15 minutes to code the solution, and explain it to him, with some sample inputs, and while we were walking through the code, I found a major bug in the code. I quickly fixed it as soon as I discovered it, and then we again walked through the code, and this time it worked. The interviewer agreed, and asked for the time and space complexity of the solution. As I spent a lot of time while explaining the approach, so we were hardly left with few minutes, so he could not ask me second question. He asked me if I have any questions, so I quickly asked him one question related to the Google.

Result

After 2 days, I got a call from my recruiter that the hiring committee has approved my packet, and that I have received very positive feedback from my last round. Then he told me that the next is Offer Review Committee, and asked few details regarding my current compensation, any other offers etc. The Offer Review Committee approved the packet, and I finally received the offer letter in my hand.

Time Management Strategy

The time managment strategy that I followed was,

  1. Solve the first problem within 20 minutes including code.
  2. Solve the second problem within next 20 minutes including code.
  3. Five minutes buffer for the general discussions and Q/A.

Break down for 20 minutes to solve the problem,

  1. 5 minutes to understand the problem and clarify all the doubts
  2. 7-8 minutes to come up with the optimal solution.
  3. 7-8 minutes to code the solution.

I'd advice to take some extra time but come up with the most optimal solution you can, in the first shot, rather than spending time on the non-optimal or brute force approach, as Google will focus mostly on the optimal solutions.

Advice and suggestions

Apart from the intense preparations before the interview, one thing that really really helped me and I would really like to suggest is to do some meditation before your interview, so as to relax your mind, which will increase the productivity of your brain during the interview.

I use to listen to this below 12 mins coding interview meditation, approximately half hour before my interview which does the positive visualization exercise where we visualize the day of the successful onsite interviews and it really helps to maintain positivity throughout the interview.

https://www.interviewcake.com/coding-interview-meditation
https://www.interviewcake.com/24-hours-before-onsite-whiteboard-coding-interview



No comments:

Post a Comment