Microsoft Interview Experience (2-3 years Experienced)
Round 1: I received a call from one of the recruitment firms 1 week before the interviews which were held in Microsoft Noida Office. The first round was a written round where we were given 2 coding questions and time given was 45 mins.We had to write code on paper.
1.) Given start and end times of people visiting a park find the maximum number of people at any point of time.
Start time End time
2.) Given a stream of 3 kinds of objects say ObjectType ob1, ob2, ob3, arrange them in such a way that equal objects are next to each other or come together.Given a compare() function as shown below:
int compare(ObjectType ob1, ObjectType ob2);
= 0 if (ob1==ob2),
After 15-20 mins of evaluation I was called for my F2F interview.
1.)Discussion on current project, he asked me several questions on how the web services are hosted, how do we take care of large number of incoming requests, why don’t we host it on cloud etc.
Then he asked me to design a stack which returns minimum element at any point of time.I explained to him the below solution wrote the complete code for it.He mainly checked for corner cases and error handling mechanisms I used.
Further he asked me to write all test cases and how will I test my design, how I will unit test my function. Next he asked me to make the class Generic.
He asked one more coding question:
Reverse a linked list in groups of k.
It is very important to write clean code which covers all the test cases in short production level code.
1.) Discussion on current project in detail.
2.)Write a code to find whether a string is a palindrome or not.
3.)Write a code to find whether any permutation of a given string can form a palindrome. I first calculated the frequency of each letter and depending on even and odd length palindrome returned the output.The latter should contain one letter with odd frequency.
4.)Write a code to find which permutation of a string can result in a palindrome.
First create all permutations of a given string and then check which one is palindrome.
5. Design a wall clock which will be displayed on an app. As and when time changes the needles should align their position accordingly.
I created a class diagram for classes Clock, Needle and how they will be related.He asked me what functions I will use, design patterns, whether to use it inheritance or composition and why?
This was the Hiring Manager round he first asked me how did my previous rounds go, I told him where I did really well and where I could have done better.He asked me to optimize the coding question I solved in written round
where expected complexity was O(N).
Then he asked me a coding question where I had to find the second largest element in a BST where I should not traverse the entire tree.
I had to write complete code with proper syntax and covering all test cases without using global variables.
Further he asked me why do I want to change my job, why Microsoft?
After this round the HR told me that I am selected!! 🙂
Thanks to GeeksForGeeks which helped me throughout my preparation.