Hi all, I recently gave an interview at microsoft for a particular team. I got this opportunity via referal.
There were around 30 people who came for the interview process, some were experienced and some were freshers like me. As there were around 30 people, no written round or group fly was taken.
Now coming to the interview process, I went through 4 rounds where each one was an elimination round.
Round 1 (50 min):
- Find the maximum width of a binary tree.
Suppose any node is at level k (level of the root is 0), then level of right child is k+1 and level of left child is k-1. So the maximum width is calculated as maxLevel – minLevel.
1 / \ 2 3 / \ \ 4 5 8 / \ 6 7
Here maxLevel is 3 (node 7) and minLevel is -2 (node 4). So maximum width is 3-(-2) = 5.
Initially I did it using some parameters in the function call. Then the interviewer told me to do it without using any extra parameter other than root and currentLevel of the node. And I did it so. And then he told me that there is a field maxWidth in every node and for each node as a root i need to store the maximum width of the subtree in the field maxWidth.
- After that he gave me a code in java and asked me some questions on that code related to OOPS concepts.
Round 2 (75 min):
- Find the sum of nodes occuring in the longest path in a binary tree.
I did it using parameters to track current maximum path length found and its sum. Whenever I found a path length greater than the current maximum path length, I updated the maximum path length and sum. After this he modified the problem and told me to handle the code for multiple operations like product, XOR etc. As I was using function parameters for keeping track of sum, it would not be feasible for taking a parameter for each operation. So I created a class having fields for each operation and was using the object as a parameter.
- Sort the array containing 0, 1 and 2.
Round 3 (60 min):
- The interviewer asked me about the things I did in college and based on that he asked me to design an online coding judge (like codechef). He asked me to implement it using classes. He asked me about how to efficiently handle the code written in different programming languages etc. A lot of discussion happened over this question.
- He asked me to design undo and redo functions of a text editor.
Round 4 (50 min):
- Given a binary tree, check whether it is BST or not.
- The interviewer asked me to design a search engine. The search engine has to search for a token in a collecion of documents and should be able to find the documents in which the token is present along with the frequency of the token and the position (index) of the token in the document. He asked me to write a full working code, I did it using trie data structure.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Amazon Interview Experience | SDE-1 offcampus
- Amazon Interview Experience Offcampus for SDE-1
- Microsoft Interview experience for full time position of software engineer at Microsoft Ireland Research
- Microsoft Interview Experience (Full Time 2018 Washington DC - with 2.5 years of experience)
- Microsoft Interview Experience | Set 169 (SDE 2 for 3.5 years experience)
- Microsoft Interview Experience | Set 151 (SDE-2 3.5 years experience)
- Microsoft Interview Experience | Set 56 (For SDE 2)
- Microsoft Interview Experience | Set 54 (For SDE)
- Microsoft Interview Experience | Set 53
- Microsoft IDC Interview Experience
- Microsoft Interview Experience | Set 45
- Microsoft IDC Interview Experience | Set 88 (For SDE-2)
- Microsoft Interview Experience | Set 89 (For SDE-2)
- Microsoft IDC Interview Experience | Set 37B
- Microsoft Interview Experience (SDE II)