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

SDE - Intern

Microsoft
upvote
share-icon
2 rounds | 4 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 2 months
Topics: Data Structures, Operating System, OOPS, Project, CN
Tip
Tip

Tip 1 : Practice Questions and focus on grabbing the concept rather than increasing the count.
Tip 2 : Whatever Keyword you use in your CV- Projects or skills known should be well prepared and in-depth Knowledge of the Project such as how to make it Efficient, shortcomings, and Scalability issues should be known.
Tip 3 : Work on Communication skills, very important for MNCs.

Application process
Where: Campus
Eligibility: 8 CGPA
Resume Tip
Resume tip

Tip 1 : Include good projects and have in-depth knowledge about them, this would increase the chances of your resume getting shortlisted
Tip 2 : Only mention relevant and known skills because it is quite possible that the interviewer starts asking questions about any of those topics.

Interview rounds

01
Round
Easy
Online Coding Interview
Duration90 minutes
Interview date25 Jul 2022
Coding problem2

The Test was online on Microsoft's platform, there were only 2 coding questions in this round and almost all the students had done both of them so the shortlisting was done on Resume(Primarily on CGPA)

1. Minimum Deletion Cost to Avoid Repeating Letters

Moderate
0/80
Asked in companies
AppleMicrosoftTesla

Ninja has given a string 'S' of lowercase characters of size 'N'. He also has provided an array 'COST' where 'COST[i]' refers to the Cost of deleting the ‘i’th character in the string.

Ninja doesn't like a string with the same adjacent characters, so he asked you to help him transform the given string into the string with no adjacent repetitive characters by deleting some characters in it.

Cost of deleting some characters is the sum of costs of individual deletion of characters at every position. Your task is to find the minimum cost needed to transform the string with no adjacent repetitive characters.

Example:
Input: 'S' = "babbc", 'COST' = [1, 2, 3, 4, 5] 
Output: 3

By deleting the third letter 'b' with cost, 3 will transform the string into 'babc'. This is the minimum possible cost to transform the string.
Problem approach

We will traverse the string from left to right. For each substring that contains the same characters, we calculate the sum of the costs and the maximum cost mx. We add sum-mx to the answer.
I have attached the code for reference:
class Solution {
public:
int minCost(string s, vector& cost) {
int i = 0, N = s.size(), ans = 0;
while (i < N) {
int j = i, sum = 0, mx = 1;
for (; i < N && s[i] == s[j]; ++i) sum += cost[i], mx = max(mx, cost[i]);
ans += sum - mx;
}
return ans;
}
};

Try solving now

2. Minimum Cost to Connect All Points

Moderate
30m average time
70% success
0/80
Asked in companies
MicrosoftOracleAmazon

You are given an array, ‘COORDINATES’ that represents the integer coordinates of some points on a 2D plane. Your task is to find the minimum cost to make all the points connected where the cost of connecting two points: (x1, y1) and (x2, y2) is equal to the manhattan distance between them, i.e., |x1 - x2| + |y1 - y2|.

Note:

1) An element of the ‘COORDINATES’ array is a pair of ‘X' and ‘Y’ coordinates of a point, i.e., COORDINATES[i] =  (Xi, Yi).

2) |DISTANCE| represents the absolute value of distance.

3) All points are considered to be connected if there is exactly one simple path between two points.

4) According to Wikipedia, a simple path is a path in a plane that does not have repeating points.
Problem approach

The problem requires us to calculate the longest path using an adjacency list and keeping a variable mx to keep a count of max. I have attached the code for reference:
#include

int longest_path(int node,int parent, bool odd,vector adj[])
{
if(odd &&(node%2==1))
return 0;
int mx=0;
for (auto adjNode:adj[node])
{
if(adjNode!=parent)
{
bool sOdd=odd| (node%2==1);
mx=max(mx,longest_path(adjNode,node,sOdd,adj));

}
}
return mx+1;
}

int solution(vector&T)
{
int n=T.size();
vectoradj[n];
for(int i=0;i {
if(i!=T[i])
{
adj[i].push_back(T[i]);
adj[T[i]].push_back(i);
}
}

return longest_path(0,-1,false,adj);
}

Try solving now
02
Round
Easy
Video Call
Duration40 minutes
Interview date1 Aug 2022
Coding problem2

The Interview round was after the OA and 20 students were shortlisted for this round(I was one of them).It was in the morning and since it was on campus we had got interview link from Training and Placement cell of our college for the same.

1. First Bad Version

Easy
10m average time
90% success
0/40
Asked in companies
FacebookMicrosoftAmazon

You are a product manager and currently leading a team to develop a new version of a product. Unfortunately, the latest version you are working on fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.

Suppose you have an array of N versions [1, 2, ..., N] and you want to find out the first bad version, which causes all the succeeding versions to be bad.

Consider we have a function isBadVersion(version), this will return whether the version is bad or not.

For an example, suppose n = 5, and version = 4 is the first bad version. So if the isBadVersion(3) returns false, isBadVersion(5) returns true and isBadVersion(4) also returns true, then the first bad version is 4.

You should minimize the number of calls to the API.

Note :
bool isBadVersion(version) returns true for all versions ‘V’ such that V > X, where X is the first bad version.
Problem approach

It was a very simple binary search problem, I initially told the interviewer about my approach. The first approach was Brute force that is linear seach after which he asked me to optimize it and then i told him about muy approach of linear search to reduce complexity and he asked me to code it.
I have attached it for reference:
bool isBadVersion(int version);

class Solution {
public:
int firstBadVersion(int n) {
int l = 1, r = n;
while (l < r) {
int m = l + (r - l) / 2;
if (isBadVersion(m)) r = m; else l = m + 1;
}
return l;
}
};

Try solving now

2. DBMS Questions

Types of Joins
How to choose primary key?
What are views?
What will you do if you want the top 5 records from a table?

Problem approach

Tip 1 : Read SQL Queries
Tip 2 : Read DBMS interview questions
Tip 3 : Focus on Keywords

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
15606 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