Hi all, I recently gave an interview at Microsoft for a particular team. I got this opportunity via referral.
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 the level of the right child is k+1, and the level of the 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 occurring in the longest path in a binary tree.
I did it using parameters to track the 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 the 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 discussions 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 collection 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 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
- Mahindra Comviva Interview Experience 2020 (Product/Software Development OffCampus)
- 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 151 (SDE-2 3.5 years experience)
- Microsoft Interview Experience | Set 169 (SDE 2 for 3.5 years experience)
- Microsoft Interview Experience (SDE II)
- Microsoft IDC Interview Experience | Set 68 (For SDE)
- Microsoft interview Experience | Set 50
- Microsoft interview experience (For SDE-1)
- Microsoft Interview Experience | Set 166
- Microsoft Interview Experience | SDE-II
- Microsoft Interview experience | Set 106
- Microsoft Interview Experience
- Microsoft IDC Interview Experience | Set 69 (For SDE)
- Microsoft Interview Experience | Set 53
- Microsoft IDC Interview Experience | Set 37B
- Microsoft Interview Experience | Set 54 (For SDE)
- Microsoft Interview Experience | Set 56 (For SDE 2)