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

SDE - Intern

Microsoft
upvote
share-icon
5 rounds | 9 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 2 months
Topics: Data Structures, Algorithms, OOPS, Dynamic Programming, Graphs, Trees, Linked List
Tip
Tip

Tip 1 : Improve your problem-solving skills from the start only and do competitive coding.
Tip 2 : Try to expertise DS Algo for Product based companies.
Tip 3 : Work on small projects to explore the real scenario of product development.
Tip 4 : Learn how to make an effective resume and prepare according to your resume.

Application process
Where: Campus
Eligibility: All students of CS, IT, ETC, Electrical having 70% till 4th semester with no current backlogs were eligible for the profile.
Resume Tip
Resume tip

Tip 1 : Make 1 Page Resume mentioning your achievements in a quantitative manner.
Tip 2 : Participate in the renowned contest e.g. Google Kickstart, Google Hashcode, Google Codejam, Facebook Hackercup and mention their ranks.
Tip 3 : Do small projects and mention them. Prepare their application, future score and challenges faced.

Interview rounds

01
Round
Medium
Online Coding Interview
Duration90 minutes
Interview date7 Aug 2019
Coding problem3

The First Round comprised of 3 Programming Problems (90 minutes) mainly based on Competitive Coding. It was on Mettl Platform.
There were different sets of problems.
I solved all 3 problems completely in approx 45 minutes. 130 students were registered for this round and 122 attempted and 70 qualified for next round. The qualified list was quite strange few students who solved 1, 2 problems completely were not qualified and few solving all 3 problems partially qualified for next round.

1. Program to find the Roots of Quadratic equation

Easy
15m average time
80% success
0/40
Asked in companies
MicrosoftTeradata

You have been given 3 integers 'A', 'B', 'C' which are the coefficients of the quadratic equation (AX^2 + BX + C = 0). Your task is to find the real roots of the quadratic equation or report if no real roots exist (return a pair of -1).

For example:

Let’s consider the equation X^2 + 2X + 1 = 0 . We can see that the quadratic equation has no real roots. So we return a pair of -1 i.e. [-1, -1].

We can consider the equation X^2 - 5X - 6 = 0. As depicted from the equation the value of 'A' would be 1, 'B' would be -5 and 'C' would be -6. We can see that this equation has two distinct roots -2 and -3. Hence we return an array/sequence containing -2 and-3.

Note:
1. If the equation has repeated roots, return the roots twice.
2. If there are imaginary roots, return -1 twice.
3. If the root is not an integer, return the greatest integer value less 
than the root.
Problem approach

I used the formula (-B +- root(B^2-4*AC))/2*A
to get roots then now for rounding up to 3 decimal places.
Let say roots are
double r1 and double r2
Now for rounding up to 3 decimal places
r1 = round(1000*r1)/1000
similarly for r2
As round function in CPP only round to nearest
integral
then finally return r1 and r2

Try solving now

2. Minimum operation needed to convert to the given string

Moderate
26m average time
0/80
Asked in companies
SamsungAppleMicrosoft

You are given two strings 'str1' and 'str2'. Find the minimum operations required to convert str1 into str2.

An Operation is defined as:
A character from an index of a string(str1) is put at the end of it, is defined as a single operation.
 Note :
You cannot perform any operation on the string, str2.
Try solving now

3. Merging Intervals

This problem was also revolved around some story but soul idea was there were several intervals given in form l to r. We need to merge the intersecting intervals and tell the number of intervals left after merging. Eg. (1, 5), (9, 15), (2, 6), (7, 8) answer will be 3 as we will have (1, 6), (7, 8), (9, 15).

Problem approach

I first sorted the intervals in ascending order of 'R' then I traversed the intervals from left to right keeping the endpoint of the last interval and checking if it's intersecting with new interval or not and updating answer accordingly.

02
Round
Hard
Coding Test - Pen and paper
Duration45 minutes
Interview date7 Aug 2019
Coding problem0

This was the group fly round and there was a problem-related to algorithm design to manage an Airport considering all the constraints of the Airport given by them. There were 3 sections of the problem Algorithm, Data Structures Used, Test case scenarios.

26 students qualified for next round out of 70.

03
Round
Medium
Face to Face
Duration45-60 minutes
Interview date7 Aug 2019
Coding problem1

This was the first Technical Round.
It revolved around Resume, Projects, Problems Solving and OOPS.

First He asked me to tell me about yourself. I told him that I love to do CP and I was having good achievements in my CV related to CP. But he hasn’t asked anything related to CP.
He told me to pick any one of your projects and explain it to me. I explained to him thoroughly and he asked a few doubts and I cleared them and it went good. Then he asked me to pick one more project and explain it to me. This also went the same as earlier. I was having a total of 5 small projects.
 

Then he asked me that do you know OOPs. I said I will be having this subject in my current semester but I studied by myself. So he asked me to explain inheritance. I explained with an example. He told me to write code in any language. He then asked me that can we inherit a protected or private member of a base class as a public member in child class. He asked me the meaning of inheriting with different classifiers like public, protected, private and asked about the reason behind that. I was not so sound on OOPs so I gave my answers with disclaimer that I am not so sound in OOPs.

1. Diagonal Traversal of binary tree

Moderate
20m average time
80% success
0/80
Asked in companies
MicrosoftSamsungBoston Consulting Group

You have been given a binary tree of integers. You have to return all the diagonal paths of the binary tree. A diagonal path is one in which all the nodes pass through -1 slope line.

A binary tree is a tree in which each parent node has at most two children.

Note:

Order of return of diagonal path’s array/vector: The rightmost diagonal path must come first, and so on.
Every parent node comes first then the child node. In other words, return the diagonal element from top to bottom.

Example

Consider the given binary tree.

subsequence

There are 4 diagonal paths:
1 3 6
2 5 9
4 8
7
You need to return ‘1 3 6 2 5 9 4 8 7’.

Let's consider this example

subsequence

Diagonal paths are:
1 3 6
2 5
4

You need to return ‘1 3 6 2 5 4’.
Try solving now
04
Round
Medium
Face to Face
Duration45-60 minutes
Interview date7 Aug 2019
Coding problem5

This was the second technical Round.
This time I got a female interviewer and she was more friendly, she was already impressed by my achievements of competitive coding. She said you have so many achievements So, you will have difficult problems. I said I will try my best.

1. Total Number of BSTs using array elements as root node

Moderate
15m average time
90% success
0/80
Asked in company
Microsoft

You are given a sequence array 'ARR' of ‘N’ integers. For each ARR[i] where 0 <= ‘i’ < 'N' , your task is to find the number of Binary search trees(BST) possible with elements of sequence ARR as nodes and ARR[i] as the root node.

The answer could be very large,so output your answer modulo (10 ^ 9 + 7). Also, use modular division when required.

For Example:

Let the sequence be 1, 4, 5, 6, 7 then return 14 5 4 5 14 i.e when 1 is the root node the number of BSTs possible is 14. Similarly, when 4 is the root node the number of BST’s possible is 5. In a similar way, we calculate the number of BST’s possible for the remaining elements of the sequence.
Note:
1. Consider 0 based Indexing.

2. A Binary Search Tree is a special kind of tree in which each node of the tree has at most 2 children and for every node, the value of nodes of the left subtree of any node is less than the current node and value of nodes of the right subtree are greater than the current node. 
Problem approach

I tried solving the problem using recursion ignoring the constraint of even numbers. So I was able to figure out the DP relation of Catalan number. Then I observed that we can only keep the numbers greater than greatest even number on root and rest we can use our Catalan number observation to get the final answer. She didn't ask me to code, she was fine with approach only.

Try solving now

2. Swap Number Without Temporary Variable

Easy
15m average time
85% success
0/40
Asked in companies
SAP LabsBNY MellonMakeMyTrip

Given two variables ‘X’ and ‘Y’. Your task is to swap the number without using a temporary variable or third variable.

Swap means the value of ‘X’ and ‘Y’ must be interchanged. Take an example ‘X’ is 10 and ‘Y’ is 20 so your function must return ‘X’ as a 20 and ‘Y’ as a 10.

Problem approach

I answered all the possible ways. She also asked me to determine which number is greater among 2 numbers using Bitwise Operators. I was thinking about that problem and I was not able to find anyway and she interrupted and said it’s okay I also forgot small things.

Try solving now

3. Project Discussion

Next, she jumped to my very small project of Line Following Bot and we discussed it’s working.

4. Minimum steps to reach target by a Knight

Moderate
25m average time
60% success
0/80
Asked in companies
MicrosoftIntuitGroww

You have been given a square chessboard of size ‘N x N’. The position coordinates of the Knight and the position coordinates of the target are also given.

Your task is to find out the minimum steps a Knight will take to reach the target position.

alt text

Example:
knightPosition: {3,4}
targetPosition: {2,1}

alt text

The knight can move from position (3,4) to positions (1,3), (2,2) and (4,2). Position (4,2) is selected and the ‘stepCount’ becomes 1. From position (4,2), the knight can directly jump to the position (2,1) which is the target point and ‘stepCount’ becomes 2 which is the final answer. 

Note:

1. The coordinates are 1 indexed. So, the bottom left square is (1,1) and the top right square is (N, N).

2. The knight can make 8 possible moves as given in figure 1.

3. A Knight moves 2 squares in one direction and 1 square in the perpendicular direction (or vice-versa).
Problem approach

I explained the solution but she asked me is it possible to do it with DFS? and Why BFS? why not DFS? I explained her the approach from both perspective and proved BFS is better.

Try solving now

5. System Design and Technical Discussion

She said I think it’s already been 40 minutes, So I should leave you and she asked me to ask questions to her. I asked her that we learn these DS and Algo. How we are going to use these in real-life projects. She said now you have raised problems for yourself, I will ask you 2 more questions. The whole conversion was very light and friendly. She asked problems related to developing products.
She asked me to make an ATM, that was a simple implementation taking care of some constraints. Then she asked me to design an algorithm for TinyURL conversion from normal URLs and vice-versa. I explained solutions using a polynomial hash. PS. she just wanted to hear the solution. I don’t have to code these problems.
She directed these solutions and said she this is how you use DS Algo in developing products and that’s All.

05
Round
Easy
HR Round
Duration10-15 minutes
Interview date7 Aug 2019
Coding problem0

We were having this round over video conferencing with HR over Microsoft Connect over laptops.
He first explained that your technical skills will not be assessed in this round.

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
3 rounds | 8 problems
Interviewed by Microsoft
2318 views
2 comments
0 upvotes
company logo
SDE - Intern
3 rounds | 6 problems
Interviewed by Microsoft
1353 views
0 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