You are on page 1of 2

Microsoft Interview Experience

Following popular request, the following is an account of my experience at the Microsoft interview: Aptitude test: 2 rounds. - 1st round: 50 questions 30 general aptitude type, 20 pseudo code type. The pseudo code type questions had no coding- just identification of error, correct o/p etc. - 2nd round: Pure coding round- just write code and submit (no compilation). There were three questions in this round: o Given an array and a number N, find whether there are tuples in the array with difference equal to N. o Insert an element into a sorted circular linked list. o Given a BST and an element N, output the leftmost node at the same level at that element in the tree. N.B.: Both the rounds were online. 26 people were short listed from the aptitude test, out of which I was in the bottom 13. That meant another written test for me (which I later came to know, was also counted as a round of interview ;)). This test consisted of two questions: - Given two linked lists representing two numbers, each node containing the character representation of a digit in the number, return a new linked lists representing their sum. - Implement the strnstr() function in C from scratch. That is, find the nth occurrence of a string inside the other, without using any library functions. 1st round: This round tried my patience! It was almost exclusively a discussion of my areas of interest. I said network security so he went into the details of cryptography and attacks like buffer overflow. That went on for say 50 minutes or so. After that he asked me a coding problem. The problem was to compress a string in place. Having seen the famous string expansion in place problem many times, I promptly said run length encoding (i.e. compress aaaaaabbbbbccc to a6b5c3 for example). He asked me to code it and write a few test cases for it. Observations: This guy caught me on whatever word I uttered, which meant you need to be thoroughly prepared with whatever you say there. He knew literally everything and asked me to give ideas on weird things that he assumed I knew! 2nd round: This was a nice, pure problem-solving round. First, he asked me the famous Tell me about yourself and How were your earlier rounds questions. But trust me, they were only ice-breakers. Then he started his session. He asked me to tell him beforehand if I knew the solution to any problem. The following were his questions:

WAP to print a matrix spirally. I told him I knew the problem so he skipped it. Search for an element in a rotated sorted array (of course in sublinear time!). I tried a twist to binary search using rotations, but he pointed out an infinite loop in my code, which I failed to correct! Then he changed the question to find the number of rotations in such an array in sublinear time. This also I could only solve for distinct elements. So he went to the next question. Really nice DP problem. Given an amount and an array containing possible coin denominations, determine the smallest no of coins in which the amount may be formed. Assume you have infinite units of each denomination.

Observations: This guy was a cool one! He focused on only the problem solving skills and was able to catch any damn error, however small, in the code absolutely quickly. He focused on the way the problem is approached, at least as much as on whether one gets the solution. 3rd round: This was the hardest and best round. The interviewer was a final round specialist! First, he asked me about my internship, which I explained to him. He discussed it for hardly 10 minutes. Then he started his attack! Even this guy told me that if I knew a question, I should ask him to skip it. There were three questions here: - Given a linked list, swap its nodes pair-wise. This is not so simple as it looks, trust me. It has more edge cases than apparent and was a true test of pointer manipulation. - Given an array, bring all its distinct elements to the top in whatsoever order; the rest of the array is not important. First I suggested in O(n) space. Then he asked me to do it without extra space. I needed a sorted array for that, which he asked me to assume. Then it is solvable under the required conditions. - Given a matrix, find an element that is max in its row and min in its col. However, he said in the end, this was not the question. The actual question was whether there can be more than one such element in the matrix, assuming all elements are distinct. Wrote a small proof that there cannot. Observations: This guy observed everything from the problem solving approach to the code quality to how fast it is coded. And he tries to bombard you with as many questions as he can to really check every aspect. Advice: 1. One is expected to really know to code. Must have a good understanding of pointers and the ability to manipulate them quickly. 2. These guys focus a lot on data structures, especially the basic ones like linked lists and binary trees. I felt these are the topics with max weightage (just my personal opinion!). 3. Again my personal opinion: Rather than study many problems from various sites, one should try to solve them, even if a few, on ones own.

You might also like