Microsoft came on our campus on 5th August 2017.

**Round 1: **It was an online coding round in which 3 questions were asked. People with 7+ CGPA were allowed to sit. More than 250+ students participated in this round. The three questions asked in my test were ( every student got different questions):

- Find the leaders in an array. Its a geeks for geeks question. Please refer to it.
- The second question was to find the maximum length of common suffix and prefix in a string.
- The third question was, a tree was given and along with left and right pointers, a next pointer was given in which we need to connect every node’s next pointer to its right sibling. If a node has no right sibling, make next pointer NULL. It can be solved using a queue. Expected Time complexity: O(n)

It was a 75 minutes coding round and I solved all the three questions in 17 minutes. Only disadvantage or consider that as a challenge that Microsoft takes the 1st round on cocubes where when you submit a question, you get to see only 2 test cases. So you have to take care of time complexity here. If you write a code which has bad complexity then it might run for those 2 test cases but may not run for other hidden test cases. So, be careful.

**Round 2: **Around 50 students got shortlisted and I was one of them for the second round. Microsoft then came on campus on 4th November 2017. It was a group fly round in which 5-6 students are given a mentor and all the students are given 2 questions. We need to solve them on paper pen within 45 minutes. Here, you were asked to write an optimal code, explain the code and write its test cases. Keep on talking with the mentor and try to discuss your approach with them. Our questions were:

- An equation was given like this: 27*63 + n Parts + 337/32. We needed to reverse it and output it like 32/337 + n parts + 63*27. I solved this in O(n) time complexity and O(1) space complexity.
- This question was little tricky. We were given a 2-D matrix. You can go in 4 directions: up, down, right and left. You needed to find the length of the longest increasing subsequence path. It can be solved using DP, but I was not able to apply DP due to time constraint so I solved it using recursion but my mentor seemed okay with it.

Question was :[ [9, 9 , 4]

[ 8, 1, 8]

[ 5, 4, 9]]

So the answer should be 4. Longest path is 4->5->8->9.

**Round 3:**

After 1 hour, results were announced and I was selected. Approx 25 students were selected for interview and after getting selected my interview got started in just 5 minutes.

My interviewer was my mentor during my group fly round. She was a very calm and cool interviewer. She started the interview by asking me to introduce me, then I told her about my Machine Learning Projects.

- After talking on ML, she started asking coding questions. She told me that as you were stuck in the 2nd question of group fly, I would ask you array questions. I was very happy from inside as I had prepared it really well. So, she asked me a very easy question. It was based on Kadane’s Algorithm.
- First, I told her that it could be solved in O(n^3). Then I told her the kadane’s algorithm approach and gave her O(n) solution. She then asked me to write code for it. Then she told me she wanted to increase the level of the question, so she asked me if I was comfortable in it. I said yes and then she asked me how will you find the length of the longest substring in an array.
- I again gave her the O(n^3) approach. She told me to do it in O(n). So I did solve it in O(n) using Dynamic Programming. She then wanted to confuse me by asking what happens if there are more than 1 substring of maximum length, I told her the answer. T
- hen she asked me what to do if I want to print all those substrings. I gave her the answer. Then she asked me to code it on pen paper. In the End, she was satisfied.
- She asked me the final question that if 2 numbers (digit by digit)are stored in a linked list in reverse order, how will I add them and store it in a new linked list. I told her my answer and coded the same.
- Then she told me to tell all the test cases for it. I gave her the maximum test cases but she was expecting more test cases. Then she herself told that there can be a test case if the numbers are floating point numbers. Then she asked me if I wanted to ask any question to her, I asked her 2-3 questions and in the end, she was satisfied and told me to wait outside.

**Round 4: **Just after 5 minutes, I got called for the second interview. The interviewer was a 45-50 old experience guy.

- He started the interview by asking HR questions like Why Microsoft should select you?
- Why are you better than other people? He was very impressed by my resume ( after seeing co-circular activities).
- Then after 20-25 minutes of HR, he started asking me a coding question.
- The first question he asked me was that there is an infinite stream of numbers and you have to give the median everytime a number is added (question can be found on geeks for geeks).
- First, i gave him O(nlogn) approach but after thinking for some time, I gave him O(logn) time approach using Heap. He was impressed.
- The next question he asked was you are given a number, let’s say 9733, then you have to find the next smallest higher palindrome number i.e. 9779 (must be bigger than 9733 and it should be smallest, like 11111 is bigger than 9733 but definitely 9779<1111, So 9779 should be output). I, first of all, got stuck in this question but then he gave me some hint and I was able to solve it. He asked me to code it. I did it.
- He was very happy. We shook hands and he said that we’ll tell you the results. I was shocked as i was expecting 2 more interviews.
- I asked him that if that was my last interview, he said yes and told me to wait outside.

After 5 mintues, the Microsoft co-ordinator called me and told me that i have been given offer to Microsoft IDC, hyderabad and i was really speechless at that moment :’). Best moment of my life. I just want to give advice to you all that keep practicing coding on GFG (i did GFG very sincerly from 2 months before interview) and now will be going to hyderabad next year. Thank you GFG 🙂

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.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** and **Microsoft** Test Serieses.