Round 1(25-30 minutes):
Interviewer was very friendly. He started by asking tell me something about yourself. I told him about my interest in competitive coding(since I am weak in probability, I always mention about competitive coding in my introduction so that the interviewer asks me coding questions).
I couldn’t solve this question completely. Maybe I was nervous or so. I did give him 2 or three approaches but they were incorrect.
Ques 2: https://www.geeksforgeeks.org/minimum-number-platforms-required-railwaybus-station/
Pretended that I am seeing this question for the first time(don’t know whether he bought it or not XD). Told him the solution after few minutes of thinking.
Ques 3: Given cities and roads connecting them. Roads are of three types: type 1-> 2 wheelers road, type 2 -> 4-wheelers road and type 3-> both 2 and 4 wheelers road. The problem was to find the max number of roads that can be removed s.t a path exists for every pair of cities for each 2 wheelers and 4 wheelers.
(Told him the brute force solution and he was convinced).
Round 2(30-40 minutes):
Ques 1: First question was of probability. An archer is hitting the target(a circle). He fires the first shot and then second shot. GIven that his shot was better than the second. Find the probability that the third shot that he fires is best among the three. The three shots are independent of each other.
Couldn’t find the answer but I did the analysis in front of him.
Ques 2: https://leetcode.com/problems/best-time-to-buy-and-sell-stock/
Ques 3: Find the min depth in a binary tree.
I gave him the dfs approach. He asked me to optimize it(in case of skew trees). I proposed level order traversal. He didn’t know what level order traversal was! Had to explain him.
Round 3(30-40 minutes):
Ques 1: System Design: Design a job scheduler. Tasks will be given as inputs with an extra parameter ‘delay’ meaning that task has to run after this ‘delay’ time.
Gave him the solution using multi-threading.
Ques 2: https://www.interviewbit.com/problems/gas-station/
Again pretended that I didn’t know the solution.
He asked me if I know about segment tree then about the lazy propagation(I said yes). Then he asked the following question
Ques 3: Normal segment tree with update operation on [l, r] and some constant value x s.t add add x to a[l], x+1 to a[l+1], ……., x+r-l to a[r]. Normal range query i.e calculate the sum in [l, r].
Couldn’t solve the question even after his hints. It even took like 5 minutes just to explain me the solution. Pretty embarrassing for me.
Then he went on to ask how to calculate the prefix sum of an array. Then asked me to think about improving the linear time complexity using multi threading. Basically he was guiding me to the solution.
Round 4(20 minutes):
This was again technical!
The interviewer was cool. First of all started with “Why GS?” I gave him the general answer which I have prepared for all the companies. Then he started asking questions:
Ques 1: Probability: Given a point on the perimeter of the circle and an interior point. Find the probability that the rectangle formed with diagonal as the line segment joining these points lies inside the circle.
He helped me a little.
Before asking this question the interviewer told me: Tell me if you have seen this question we will end this round here only.
Ques 2: https://www.cut-the-knot.org/pigeonhole/FiveCouples.shtml
I solved this question.
Total 9 were selected by G.S(including me).
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course. In case you are prepared, test your skills using TCS, Wipro, Amazon and Microsoft Test Serieses.