Microsoft Interview experience | Set 102 (On Campus for IDC)
Around 150 students appeared for the test.
Round 1 (75 minutes):
Online coding round hosted on HackerRank . Three coding questions were asked.
- Given a Linked List of integers, write a function to modify the linked list in-place such that all odd numbers appear before all the even numbers in the modified linked list. The relative order of even and odd numbers should remain the same. – https://www.geeksforgeeks.org/segregate-even-and-odd-elements-in-a-linked-list/
- Given a floating point number, calculate its square root without using in-built sqrt() function.
- Given a pattern string and a test string, implement RegEx substring matching. If the pattern is preceded by a ^, it will match with the starting position. Similarly, if it is preceded by a $, it will match the ending position. If no such markers are present, it will check whether pattern is a substring of test.
Ex : ^coal coaltar Result : True tar$ coaltar Result : True abcd efgh Result : False
25 students were selected for the next round.
Round 2(paper coding round):
- Print boundary traversal of Binary tree in clockwise direction.(Note: check for leaf nodes in left and right traversal for a given tree). – https://www.geeksforgeeks.org/boundary-traversal-of-binary-tree/
- Rotate a square image 90 degree clockwise. Optimize as much as u can. Similar Question: https://www.geeksforgeeks.org/inplace-rotate-square-matrix-by-90-degrees/
8 students were selected for further rounds.
Round 3 – Personal Interview 1
- Discussed about the 1st question asked in paper coding round, i.e., Boundary traversal of Binary tree.
- How to merge two BSTs . Asked me all the approaches that I was able to implement . Then asked me to do in O(logn), where n is total no. of nodes .
- Asked me to write code to find a no. occurring greater than n/2 times in an array . Then asked me to prove the written algorithm , basically , he was asking how I was able to write that code and why is it working .
7 students were selected for further rounds.
Round 4- Personal Interview 2
- Asked me to implement seat booking process in BOOKMYSHOW.com . How to handle the cases where two persons are trying to access the same seat at almost same time . He told me to write class based solution asking about different functions that should be used to solve all the cases for booking procedure .
- What is singleton class?
- How to find the point of intersection of two line segments . Two end points of line segments were given.
- How to find no. of 2’s between nos. 1 to n . He gave me few hints and finally , he was satisfied with my approach
- Implement fibonacci series considering every possible solution .
And few more questions were asked , but I don’t remember them. 6 students were selected for further rounds.
Round 5- Personal Interview 3
- Write function for inorder traversal of Binary tree without recursion. That was easy !!
- Asked me a puzzle question. An n*n board is given and one of the given cells is black .Also , L shaped pieces are given (equivalent to 3 cells of given matrix) , considering all possible rotations. I had to fill the entire grid using those pieces . Pieces can’t be placed on the black cell and no two pieces should overlap , not even partially . I gave an answer where I tried to increase the size of unaccesiblecells( black cells and already placed pieces on board) to the size of the given board , but he asked me few cases where my answer failed. Then I said him we can do the exhaustive search of combinations using backtracking but it will take too much time . Then he gave me clue that instead of growing the size of unaccesible cells, try to decrease it. Finally , I concluded that it divide-n-conquer based solution considering base case as 2*2 board with 1 black cell.
4 students were selected for further rounds.
Round 6- Personal Interview 4
He told me to implement LRU Cache . I gave him all the solutions that can be possible . He was very helpful . He found flaws and told me to optimize it. I gave him 3 solutions and the final one is the one which you can find anywhere on the internet. But before that , he asked me to swap two nodes of a DLL using hashmap . I didn’t know what Lru Cache is initially .haha
Round 7- Personal Interview 5
- What’s your passion ? What you want to do in your life ? Hr-type question .
- He designed a new language with the words of English and stored them in an array of strings . Then he gave me two strings and told me to design strcmpfunction . I told him the best method in one go , but he tried to confuse me and he was successful . He gave me 5 mins to come up with another solution and tried new one .Lastly , I implemented the first approach I had in mind and he was satisfied with it.
- How to serialize and deserialize an n-ary tree . I told him the function for serializing and deserializing a binary tree but couldn’t come up with solution for the given problem.
3 students were finally selected for MS-IDC. I was one of them. :p
P.S : I was not comfortable with OS and DBMS , so I told them clearly but they tried to ask indirectly all the basic questions of OS and DBMS , and told me to implement them using C/C++.
Questions asked to my friends :
- Developing an algorithm for crossing bridges problem , where no. of elements is n.
- Intersection of two linked lists.
- Find if loop is present in linked list and also ,find the start node of the loop in it .
- Class design for banking system.
- Reverse linked list using both recursion and iteration etc etc
If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to firstname.lastname@example.org. 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
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. Google and Microsoft Test Serieses.