Microsoft Interview Experience for Internship
Recently Microsoft visited our campus for internships. They had a coding round which was followed by 3 interviews ( 2 technical and 1 HR).
Online Test: It was conducted on mettl and we had 90 minutes to solve 3 questions. Questions were shuffled for everyone but were fairly easy.

Given a string we need to return a string in which each character should be increased by 3 units.
Eg.
adz > dgc
The a becomes d, d becomes g and z becomes c. The only trick here was that we just had to complete the given function and they passed the string as a character pointer and so you need to see how to traverse a string represented as a character pointer.

Given a string in form of num1+num2=num3 in which one of them is X we need to find the value of X.
Eg.
Input : 5+X=7 Output: X= 2 Input : 7+2=X Output: X=9
So this was basically an implementation based question and we just needed to find out of which one of them was X and accordingly find the answer.
48 students were selected for the interviews.
Round 1: I was asked 3 questions in this round. The questions were pretty easy.
 Find the max and min element at any point in a stack. I was asked to code it. I tried to keep the interview interactive by telling him my approach as I wrote the code. I was asked to do a few dry runs, and he seemed satisfied with my approach.
 Reverse a string. We discussed the stack question for about 20 minutes and I told him I will use a stack to reverse it, and he didn’t ask me to optimize it.
 Mirror a given Binary Tree. I first told him my approach that we will use postorder traversal and then he asked me to code it.
I answered all the questions, so I was pretty confident that I will be selected for the next round.
Round 2: I was asked just 2 questions in this round.
 Find the diameter of a tree (No. of nodes on the longest path in a tree). I had seen this question before and knew the solution so I just told him my approach and we did a few dry runs on sample inputs before proceeding to the next question.
 Given a number N we need to convert N to 1 by performing a minimum no of operations. The allowed operations are:
 Subtract 1 from a number.
 Divide the number by 2.
 Divide the number by 3.
Eg.
Input: 10 Output: 3 10>9>3>1
So at first, I was trying to generalize the solution by taking different cases. The interviewer asked me to change my approach and I thought of a Dynamic Programming approach.
C++
#include <iostream>
using
namespace
std;
int
main()
{
int
n = 10;
int
dp[n + 1];
dp[1] = 0;
dp[2] = 1;
dp[3] = 1;
for
(
int
i = 4; i <= n; i++)
{
dp[i] = dp[i  1] + 1;
if
(i % 2 == 0) dp[i] = min(dp[i], 1 + dp[i / 2]);
if
(i % 3 == 0) dp[i] = min(dp[i], 1 + dp[i / 3]);
}
cout<<dp[n]<<endl;
}
Output:
3
Round 3(HR): So it started with questions like tell me about yourself. I was prepared for this question and I kept the focus on my coding skills. For me, it was a mix of HR and technical round.
So, he asked me questions on Doubly Linked List. Given a pointer to a random node of a doubly linked list. Delete the node.
We discussed all the edge cases involved, and he just asked me to code it mentally and tell him each line. He seemed satisfied. Then he asked me why I wanted to work at Microsoft. It was followed by questions on OOPS and Hashing.
He asked me what was the implementation of hashing in real life and how hashing is implemented internally. I was able to answer this but I didn’t know the technical terms. Finally, he asked me if I had any questions for him. Never give a no as an answer to this question as it shows that you are not interested in knowing about the company.
Verdict – Selected
Please Login to comment...