Microsoft interview experience Real time questions & tips from candidates to crack your interview

SDE - Intern

Microsoft
upvote
share-icon
3 rounds | 6 Coding problems

Interview preparation journey

expand-icon
Journey
I started preparing for internship drive in my college from April 2021. I practiced coding questions from interviewbit and continued to learn DSA from youtube. The internship drive started in our college on August 2021. Microsoft visited campus around 20 August. First we had online Assessment round in which students were shortlisted for the F2F interviews . There were 2 technical interviews. The whole process was held in online mode.
Application story
Microsoft visited campus around 20 August. First we had online Assessment round in which students were shortlisted for the F2F interviews . There were 2 technical interviews. The whole process was held in online mode. Application was done through placement cell of our college and the process was very smooth.
Why selected/rejected for the role?
I was rejected in the 2nd interview. I was asked a question involving variable length sliding window which I was not able to explain properly at that time.
Preparation
Duration: 6 months
Topics: DSA, OOPS, DBMS, Machine Learning, ReactJS, HTML/CSS, C++, Javascript, Deep Learning
Tip
Tip

Tip 1 : Linked List and Tree (also look Trie) Data structure are interviews favourite questions. So be prepared with all questions of Linked List and Tree.
Tip 2 : Only mention courses and topics in your Resume you are confident in and it would be better if you revise OOPS, DBMS
Tip 3 : Think out loud while going over the solution of the coding or any other problem, talk with the interviewer, ask questions(like edge cases etc) about the question you have been given.

Application process
Where: Campus
Eligibility: CGPA criteria: strictly 7.5 or above and only circuital branches were allowed
Resume Tip
Resume tip

Tip 1: Only mention courses, topics and projects in your Resume you are confident in.
Tip 2: Do unique projects in the area which you want to apply to.
Tip 3: Keep updating your resume according to the role you are applying to

Interview rounds

01
Round
Easy
Online Coding Test
Duration90 minutes
Interview date23 Aug 2021
Coding problem2

The Online Coding Test was conducted on Codility Platform. There were 2 questions. First was a debugging question. Other was a coding question.

1. Debugging Question

A debugging question in which the buggy code and the question was given and we had to change at most 2 lines of code to make the code run properly. The following code runs fine for smaller inputs but not for the larger inputs. Optimize the code without changing the functionality

public int sol(int[] A){

int N = A.length(), result = 0;

for(int i=0;i<N;i++){for(int j=0;j<N;j++){if(A[i] == A[j]) 

result = Math.max(result,Math.abs(i-j));}}

return result;}

don't remember the exact question but the pattern was something like this:

Problem approach

Step 1 : It was quite an easy problem in which we just had to increase the efficiency of the code.
Step 2 : I changed the required line to solve the question. At max 2 lines could have to be changed in the code.

2. 0 1 Knapsack

Moderate
0/80
Asked in companies
Disney + HotstarOptumAmazon

A thief is robbing a store and can carry a maximum weight of ‘W’ into his knapsack. There are 'N' items available in the store and the weight and value of each item is known to the thief. Considering the constraints of the maximum weight that a knapsack can carry, you have to find the maximum profit that a thief can generate by stealing items.

Note: The thief is not allowed to break the items.

For example, N = 4, W = 10 and the weights and values of items are weights = [6, 1, 5, 3] and values = [3, 6, 1, 4]. Then the best way to fill the knapsack is to choose items with weight 6, 1 and 3. The total value of knapsack = 3 + 6 + 4 = 13.

Problem approach

Step 1 : This was a variation of basic knapsack
Step 2 : I solved this question using DP top-down approach. 

A recursive solution is to try out all the possible ways of filling the two knapsacks and choose the one giving the maximum weight. 
To optimize the above idea, we need to determine the states of DP, that we will build up our solution upon. After little observation, we can determine that this can be represented in three states (i, w1_r, w2_r). Here ‘i’ means the index of the element we are trying to store, w1_r means the remaining space of the first knapsack, and w2_r means the remaining space of the second knapsack. Thus, the problem can be solved using a 3-dimensional dynamic-programming with a recurrence relation

DP[i][w1_r][w2_r] = max( DP[i + 1][w1_r][w2_r],
arr[i] + DP[i + 1][w1_r - arr[i]][w2_r],
arr[i] + DP[i + 1][w1_r][w2_r - arr[i]])

Try solving now
02
Round
Medium
Video Call
Duration60 mins
Interview date25 Aug 2021
Coding problem2

First I was asked to introduce myself and tell something about the projects I had done. I was asked to code on the Codility platform and then he ran a few test cases over the code.

1. Maximize Score

Moderate
10m average time
90% success
0/80
Asked in companies
OLX GroupCerence IncUnthinkable Solutions

You are given an array ‘arr’ of size ‘N’. Your task is to maximize your score by doing the following operation at most ‘K’ – times.

1. Choose an element from the start or end of the array and the value of the element to your score.
2. Remove the element from the array you have chosen in step – 1.
Note:
Initially, you have a score of zero.
Problem approach

Step 1 : this was an easy question. I used 2 cases for 1 digit and 2 digit scores.
Step 2 : then I selected the suitable answer from these cases. this was a simple brute force approach

Try solving now

2. Tribonacci Sequence

Moderate
0/80
Asked in company
OLX Group

You are given an integer ‘N’. Your task is to find out the ‘N’th Tribonacci Number. ‘N’th number in the Tribonacci sequence is defined as Tn = T n - 1 + Tn - 2 + Tn - 3. Where T0 = 0, T1 = 1, T2= 1. Return the answer in mod of 109 + 7.

For Example :
You are given ‘N’ = 5, Here we know 0th, 1st and 2nd Tribonacci numbers are 0, 1 and 1 respectively. Therefore we can calculate the 3rd number as 0 + 1 + 1 = 2 and 4th number as 1 + 1 + 2 = 4 and 5th number as 1 + 2 + 4 = 7. Hence the answer is 7.
Follow Up :
Can you solve it in logarithmic time?
Problem approach

Step 1 : I explained my approach of using a simple for loop with O(N) time complexity. I also explained how I am handling the border case if the length of the array is less than or equal to 3 (i.e. 0Step 2 : After the explanation he told me to code it. I did everything but by mistake I forgot to include the border case and he reminded me that you forgot something by giving a test case of length 3 . Then I correct it and include the border case also.

Try solving now
03
Round
Easy
Video Call
Duration60 mins
Interview date25 Aug 2021
Coding problem2

Soon after the 1st interview, I was informed that I was selected for the next round. First the interviewer introduced himself then I was asked for a brief introduction of myself. He was very friendly and had calmed down the interview environment.

1. Validate Binary Tree Nodes

Moderate
15m average time
85% success
0/80
Asked in companies
FacebookMakeMyTripIntuit

You are given ‘N’ binary tree nodes numbered from 0 to N - 1 where node ‘i’ has two children LEFT_CHILD[i] and RIGHT_CODE[i]. Return ‘True’ if and only if all the given nodes form exactly one valid binary tree. If node ‘i’ has no left child then 'LEFT_CHILD[i]' will equal -1, similarly for the right child.

Example:

Let’s say we have n=4 nodes, 'LEFT_CHILD' = {1, -1, 3, -1} and 
RIGHT_CHILD = {2, -1, -1, -1}. So the resulting tree will look like this:

It will return True as there is only one valid binary tree and each node has only one parent and there is only one root.
Problem approach

Approach :- The idea is to for each node, check if max value in left subtree is smaller than the node and min value in right subtree greater than the node

Step 1 :It was a simple question if you know about BSTs. I was told to code the only function for checking for valid BST.
Step 2 : Then he asked, what data type would I use to store the population of our country. To answer this question, I told him integers are 32 bit in cpp so unsigned integers have a maximum value of 2^32 and the population of our country is 1.4billion. So we can store in an unsigned integer by showing him all the steps how I reached the answer. He was quite impressed with the solutions and I moved to the next round.

Try solving now

2. Longest Subarray With Sum K.

Moderate
30m average time
50% success
0/80
Asked in companies
OLX GroupIntuitRestoLabs

Ninja and his friend are playing a game of subarrays. They have an array ‘NUMS’ of length ‘N’. Ninja’s friend gives him an arbitrary integer ‘K’ and asks him to find the length of the longest subarray in which the sum of elements is equal to ‘K’.

Ninjas asks for your help to win this game. Find the length of the longest subarray in which the sum of elements is equal to ‘K’.

If there is no subarray whose sum is ‘K’ then you should return 0.

Example:
Input: ‘N’ = 5,  ‘K’ = 4, ‘NUMS’ = [ 1, 2, 1, 0, 1 ]

Output: 4

There are two subarrays with sum = 4, [1, 2, 1] and [2, 1, 0, 1]. Hence the length of the longest subarray with sum = 4 is 4.
Problem approach

Step 1 : I first started with a brute force approach to which he was not satisfied. He then gave me some hints directing to the answer.
Step 2 : I understood that it was a Sliding window problem and explained him about it. 
Step 3 : I coded using sliding window approach but I got stuck while dry running over an example and the time was over so I could not explain him satisfactorily.

Try solving now

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

How do you remove whitespace from the start of a string?

Choose another skill to practice
Similar interview experiences
company logo
SDE - Intern
2 rounds | 4 problems
Interviewed by Microsoft
4914 views
2 comments
0 upvotes
company logo
SDE - Intern
3 rounds | 8 problems
Interviewed by Microsoft
2317 views
2 comments
0 upvotes
company logo
SDE - Intern
2 rounds | 5 problems
Interviewed by Microsoft
1985 views
0 comments
0 upvotes
company logo
SDE - Intern
2 rounds | 4 problems
Interviewed by Microsoft
632 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - Intern
3 rounds | 6 problems
Interviewed by Amazon
15605 views
4 comments
0 upvotes
company logo
SDE - Intern
2 rounds | 4 problems
Interviewed by Amazon
10216 views
2 comments
0 upvotes
company logo
SDE - Intern
3 rounds | 4 problems
Interviewed by Amazon
6389 views
3 comments
0 upvotes