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

SDE - Intern

Microsoft
upvote
share-icon
2 rounds | 5 Coding problems

Interview preparation journey

expand-icon
Journey
Working for an MNC was something I always looked forward to, and an interview at Microsoft was an on-campus opportunity for me. I started practicing coding in the middle of my sophomore year. To see my coding skills, I started doing fundamental problems on various portals, including Coding ninjas. However, at that time, it did not solve the core problem of DSA. Then, I started following a YouTube channel with about 150 issues specifically created for placements and internships. Which YouTube course or channel you choose is up to you. They started hiring a company for our industrial semester in my fifth semester. This was the first one I gave them.
Application story
This is an on-campus opportunity open to students with a GPA of 8 or higher. After a pre-placement talk, a final selection on the CGPA and resume will be made, and approximately 300 students will be tested (assessment online). ) accessible, and then 20 students were selected for interviews and interviews. Four of them received internship offers.
Why selected/rejected for the role?
I wasn't chosen for the role. One of the main reasons was that I was nervous during the interview and was not well prepared for the interview.
Preparation
Duration: 3 months
Topics: Data Structures, Operating System, OOPS, Project, CN
Tip
Tip

Tip 1 : Practice Data Structures daily as they are the key.
Tip 2 : Please reflect on Interview Experiences of your seniors
Tip 3 : Make a good project.

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

Tip 1 : Mention some good project
Tip 2 : Mention skills like C++, Database, HTML, CSS, JS

Interview rounds

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

The tests were carried out online on the Microsoft platform. Since there were only two coding questions in this round and almost all students asked both questions, the final selection was based on resumes (mainly CGPA).

1. Minimum Cost To Make String Valid

Moderate
20m average time
80% success
0/80
Asked in companies
MicrosoftAdobeAmazon

Ninja has been given a string ‘STR’ containing either ‘{’ or ‘}’. 'STR’ is called valid if all the brackets are balanced. Formally for each opening bracket, there must be a closing bracket right to it.

For Example:
“{}{}”, “{{}}”, “{{}{}}” are valid strings while “}{}”, “{}}{{}”, “{{}}}{“ are not valid strings.

Ninja wants to make ‘STR’ valid by performing some operations on it. In one operation, he can convert ‘{’ into ‘}’ or vice versa, and the cost of one such operation is 1.

Your task is to help Ninja determine the minimum cost to make ‘STR’ valid.

For Example:
Minimum operations to make ‘STR’ =  “{{“ valid is 1.

In one operation, we can convert ‘{’ at index ‘1’ (0-based indexing) to ‘}’. The ‘STR’ now becomes "{}" which is a valid string.

Note:
Return -1 if it is impossible to make ‘STR’ valid.
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. Connecting Cities With Minimum Cost

Moderate
10m average time
90% success
0/80
Asked in companies
SamsungAmazonSquadstack

There are ‘N’ cities numbered from 1 to ‘N’ and ‘M’ roads. Each road connectss two different cities and described as a two-way road using three integers (‘U’, ‘V’, ‘W’) which represents the cost ‘W’ to connect city ‘U’ and city ‘V’ together.

Now, you are supposed to find the minimum cost so that for every pair of cities, there exists a path of connections (possibly of length 1) that connects those two cities together. The cost is the sum of the connection costs used. If the task is impossible, return -1.

Try solving now
02
Round
Easy
Video Call
Duration40 minutes
Interview date2 Aug 2022
Coding problem3

Interviews were held after OA and 20 students were shortlisted (I was one of them). It was morning and I was on campus, so it was the same from the university's training and placement cells.

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

What is a view?(Learn)
What if I want the top 5 records of a table?(Learn)

Problem approach

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

3. Trapping Rain Water

Moderate
15m average time
80% success
0/80
Asked in companies
HCL TechnologiesCiti BankAtlassian

You have been given a long type array/list 'arr’ of size 'n’.


It represents an elevation map wherein 'arr[i]’ denotes the elevation of the 'ith' bar.



Note :
The width of each bar is the same and is equal to 1.
Example:
Input: ‘n’ = 6, ‘arr’ = [3, 0, 0, 2, 0, 4].

Output: 10

Explanation: Refer to the image for better comprehension:

Alt Text

Note :
You don't need to print anything. It has already been taken care of. Just implement the given function.
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
4915 views
2 comments
0 upvotes
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 | 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
6390 views
3 comments
0 upvotes