# Microsoft Interview Experience | (On-Campus for Internship)

Microsoft came to our campus a couple of days back (15 July, 2019) for offering Summer Internships to student who just finished their B.Tech second year. The CPI(Cumulative Progressive Index) criteria was 7.

**Round 1: Online Coding Round:**

So this round took place on mettl.com. There were 3 coding questions and the time allotted was 90 minutes.

- You are given n passwords. You have to print total number of distinct password. On each password you can perform operation any number of times possibly zero. The operation is defined as you can swap data present on any 2 index of a string if the difference of index number is even i.e. swap(a[i], a[j]) if (j-i)%2==0. Test Case: Input: n=5 and passwords are=[“abcd”, “cdab”, “bacd”, “bdca”, “cdba”] Output : 2 Explanation: as “cdab” can be converted to “abcd ” and “bdca”, “cdba” can be converted to “bacd” so you can get only 2 distinct password.
- Today is Tushar’s birthday so he brought n chocolates and he had k friends. He has to distribute all the chocolates to friends in the following way. The first child gets 1 second gets 2 third gets 3 and so on so if there are enough chocolates then kth child gets k chocolates. Now if chocolates are still remaining then he gives again k+1 chocolate to first child k+2 to second child and so on till he distributes all the chocolate. So you have to print k integers defining which child got how many chocolates. Test Case: Input: n=25 and k=5 Output: [7 6 3 4 5] Explanation: so in first go the chocolate distribution would be as [1 2 3 4 5] so total 15 chocolates are used now in second go 1st child will get 6 more candies so his total candies would be 7 now we are just left with 4 more candies so that would be given to second child as he can get more as much as 7 chocolates but we have only 4 left. So the final answer would be [1 2 3 4 5] + [6 4 0 0 0] = [7 6 3 4 5]
- You are given M for modulo and N number of layers. Now in first layer you have 1 ship of power v=2. Now for every ship in layer i with power v there are distinct ships of power 0 to v*(v+1)%M-1 in in its next layer. Now you are given M and N. You have to find total number ships in all layer % M. Test Case: Input: M=4 N=2 Output: 3

So in this round all the candidates who solved 2 or more than 2 question were selected for next round. So in our college around 170 candidates did gave this round and 60 moved to next round.

**Round 2: Group Fly Round**

So as you know its a basic pen paper round in this round we were given 2 question and we had to write the description of the solution and write the code on paper and give its time and space complexity.

- It was based on this question https://www.geeksforgeeks.org/print-nodes-distance-k-given-node-binary-tree/ but there was a slight change that it had weighted edges and you had to find all node at distance in range (a, b) from that given node.
- You are given a doubly link-list whose values were integers you had to determine weather it is palindromic or not. Test Case 1: Input: 123 <-> -12 <-> -21 <-> -321 Output: Palindromic Test Case 2: Input: 12 <-> -3 <-> 21 Output: Not Palindromic

Total 60 candidates gave this round all the candidates who did both the code correct no matter brute force moved to next round. So 26 candidates moved to next round.

**Round 3: Technical Interview-I**

So basically he went to through my resume and then asked me which topic I liked in coding. So, I told him that I like greedy. Then he asked me a very easy question.

Question is: You have to paint you house you have r rooms in your house now there are n painter and each painter cost ci amount per room and he can paint maximum ni number of rooms and each painter will paint minimum 1 room. You have to tell what is the minimum cost required to paint your house.

Then he asked me which technical subjects I studied and in it what all topics I studies. I think the interviewer was around 35-45 years old and was quite experienced and was very helpful. The interview took around 30-40 minutes.

**Round 4: Technical Interview-II**

So first of all he went through my group fly round paper but it was perfect so he didn’t asked anything from it. He was a young interviewer and was more brilliant. So then he asked me 2 questions.

- So he gave a input and output pattern of link-list and I had to first of all find how was that pattern formed and then write its code. Input: 1->2->3->4->5->6 Output: 1->3->5->6->4->2. So as you can see first you have to make 2 link-list first with nodes on odd indies that is 1->3->5 and other with nodes on even indices that is 2->4->6 and then reverse list which is formed from nodes at even indices which is 6->4->2 and then concatenate both the list.
- https://www.geeksforgeeks.org/detect-and-remove-loop-in-a-linked-list/ and he asked me to find all approaches I can make.

This interview took around 40 minutes as I had to write both codes on paper.

**Round 5: Technical + HR Interview**

So this was the final interview. And the interviewer was very experienced he had worked for last 18 years with Microsoft and also worked in Microsoft head quarters. So initially he asked me what all data structures I know and asked me my favorite data structure. So I told him vector. Then he asked me 1 coding question.

Question is: You are given n, m so now you have to reach from (1, 1) to (n, m) and you can only move right side and downwards. You have to print all the paths from (1, 1) to (n, m).

Then he went through my resume and asked about my projects and achievements and about my hobbies. And also asked me about my further plan.

So the result was declared immediately after the interviews of all the candidates were finished. And i got selected along with 12 others for summer internship of 2 months.

## Please

Loginto comment...