The round 1 was an online coding round. There were 2 coding questions and 28 technical mcq’s to solved in 90 minutes. My coding questions were:-
- There are n baskets containing apples. Input consists of a given array which represents number of apples in each basket. Find the minimum number of apples to be moved in order to make no. of apples in each basket equal.
- A string is given as input. There is a particular format of a url. you have to convert the given string to url. I don’t exactly remember the mcq’s but they were all on data structures and output questions in C and C++. I solved both the coding questions. Around 300 people sat for the online round and 24 were shortlisted.Some questions which came to my friends were:- Find the inversion count, evaluate a postfix expression, Dice Throw, smallest derangement, total decoding messages etc.
This was a face to face interview. the interview started with the normal question introduce yourself and then he said now we will do some coding. The first question he asked was, There is a hotel and there is a class reservation. Reservation class consists of user-id, check-in date, and check-out date. Find the day on which there are maximum users in the hotel. He wrote the function header in a paper and gave me. I t He then told him an approach by maintaining an array with index as day number. He then said to optimize the space complexity. I then told him a solution using sorting. He was satisfied. He told me to write the code.
The next question he asked was, given a binary tree with one more pointer called parent pointer which points to the parent node. Now a given any node of the tree, find it’s the first sibling. I first told him my approach, he said me too modularise it. I then wrote an recursive function for the same. then we discussed some edge cases. I was missing one edge case which I could’nt figure out. But he was satisfied so, he asked me the time complexity and the round was over.
Round 3 started with a description of my internship. He asked me several questions about it like what technologies you used. Then he asked me how good I am at operating systems. I said I am not much good. He then explained to me the importance of OS. I was patiently listening to him. Then he told me to write the code for drawing a circle given radius and assume center as 0, 0. I told him a method using sin and cos. He then told me if i can do something else. Then I told him another mathematical approach which included floating-point calculations. He told me to remove that. I then derived two conditions using which we can decide the next point. He was a bit satisfied. Then he told me the round was over. I was a little bit confused whether I will qualify or not, but I did.
This was round was taken by an SDE2. He told me to consider there are multiple packages and every package is dependent on some or none. For a particular package to be built, what is the optimal order in which the packages should be build. The answer is to use consider it as a graph and then use Topological Sorting. I told him Topological sort. He then told me to write the code for the same. After some discussions with him, I wrote a proper code for it.
The next question was Spiral Order Traversal of a Binary Tree. I first told him an approach by using more space. He then told me to optimize it. I then told him the solution using two stacks. He told me to write the code for it.
This round started with describe yourself. She then asked me about the difference between Inheritance and Composition in Java. She then asked conditions where Inheritance is a bad option and where good. She then asked me about traversals in a tree. I told her 4 traversals. She then told me to do spiral order traversal. I did it using two stacks. She then told me to use only one stack or any data structure but one. Then she told me to implement a C function. The next question she asked was an interleaving of an array. Then she told me to implement the same thing in a Linked List. She then told me given a String convert it into an integer. She then asked me some questions on networking like Virtual IP Address, how DNS works, IPv4 and IPv6, SLIP Protocol, etc. She then asked about applications of the graph. I told her Facebook. Then she asked apart from friends recommendation how facebook uses graphs. How google maps use graphs. What kind of database they have. Then the round was over.
Finally, after 6 hours of interview, I was informed that I am selected.
Stay confident and humble. Even if you know the solution, first tell the brute force and then optimize it. That too discuss this with the interviewer. Keep on interacting with him. They will guide you to the solution. Tell them your thought process instead of telling the solution straightforwardly. Every time ask questions at the end of the interview. And never tell the solution at once. Discuss the solution with them at least in the case of Amazon, this proves to be great. Because if you know the solution they will consider it as a question asked. Stay confident and trust your instincts.