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

SDE - 1

Microsoft
upvote
share-icon
3 rounds | 5 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 4 months
Topics: Data Structures, OOPs, Algorithms, Graphs, System Design
Tip
Tip

Tip 1 : Practice Leetcode throughly.
Tip 2 : Revise your core subjects.
Tip 3 : Do not ignore HLD system design, use GFG or Leetcode for this.

Application process
Where: Company Website
Eligibility: Final year college student
Resume Tip
Resume tip

Tip 1 : Keep some projects in your resume, that helps in the interview conversation.
Tip 2 : Do not add flashy items like colourful borders to your resume.

Interview rounds

01
Round
Medium
Online Coding Interview
Duration60 minutes
Interview date4 Oct 2021
Coding problem2

This was an online coding round which consisted of 2 problems to be completed in 60 mins. The test was held in Microsoft's own coding platform which had an environment same as any other platform like Hackerank with support for most of the popular programming languages.

1. Minimum Removals

Moderate
15m average time
85% success
0/80
Asked in companies
AdobeRubrik, Inc.Microsoft

You have been given an array/list "ARR" consisting of 'N' integers. You have also given an integer 'K'.

Your task is to find the minimum number of elements that should be removed from "ARR" (possibly zero) such that the difference between the maximum element and the minimum element of the remaining "ARR" is less than or equal to 'K', i.e. ARRmax - ARRmin <= K.

Note :

1. "ARR" can contain duplicates.

For Example :

Input: 'N' = 4 , "ARR" =  [5, 10 , 2] and 'K' = 3.
Output: 1

Explanation : Currently, the difference between the maximum and minimum element in the array is 10 - 2 = 8, which is greater than K (3). 
So, we need to remove some elements. The optimal way to get our result is to remove 10. After removing 10, the difference between maximum and minimum is 5 - 2 = 3, which is less than or equal to K.
Try solving now

2. Longest Palindromic Substring

Moderate
20m average time
80% success
0/80
Asked in companies
MathworksLivekeeping (An IndiaMART Company)Goldman Sachs

You are given a string 'str' of length 'N'.


Your task is to return the longest palindromic substring. If there are multiple strings, return any.


A substring is a contiguous segment of a string.


For example :
str = "ababc"

The longest palindromic substring of "ababc" is "aba", since "aba" is a palindrome and it is the longest substring of length 3 which is a palindrome. 

There is another palindromic substring of length 3 is "bab". Since starting index of "aba" is less than "bab", so "aba" is the answer.
Problem approach

Let N be the length of the string S.
Step 1. The most naive solution can be to check if every substring of S is palindrome or not but the time complexity of this would be N^2 * N = N^3 which won't pass.
Step 2. I solved this using DP.
Step 3. Let dp[i][j] = 1 if the string from index i to j is a palindrome otherwise it's 0.
Step 4. The recurrence relation would be dp[i][j] = (dp[i+1][j-1] == 1 && S[i] == S[j])
Step 5. find the max value in dp. If suppose the max value is for dp[x][y] then the final answer would be y -x + 1. Return it.

Try solving now
02
Round
Easy
Face to Face
Duration45 minutes
Interview date26 Oct 2021
Coding problem2

The round was held at 1 pm and was over before 2. It was a Microsoft teams meeting and coding was done in a live editor link of which can be shared. The interviewer was very friendly and gave me the question after having a quick round of intro.

1. Maximum Path Sum

Easy
0/40
Asked in companies
Goldman SachsMicrosoftOracle

You are given an n-ary tree consisting of ‘N’ nodes. Your task is to return the maximum sum of the path from the root to the leaf node.

For example:
For the given tree:

The path 1 -> 3 -> 7 produces the maximum i.e, 11.
Try solving now

2. Maximum In Sliding Windows Of Size K

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

Given an array/list of integers of length ‘N’, there is a sliding window of size ‘K’ which moves from the beginning of the array, to the very end. You can only see the ‘K’ numbers in a particular window at a time. For each of the 'N'-'K'+1 different windows thus formed, you are supposed to return the maximum element in each of them, from the given array/list.

Problem approach

There are many ways to solve this problem. I solved it using a deque. Create a deque such that it is always sorted in desc order from left to right and size does not exceed K. This deque acts as our window. First add the starting K elements in the deque such that when adding a new element such that all the elements to the left of it should be greater than it, if not start removing elements from the start of the deque. This will always give the max element in a subarray of size K.

Try solving now
03
Round
Medium
Face to Face
Duration40 minutes
Interview date9 Nov 2021
Coding problem1

This was the second technical round and also penultimate one. This was held in the afternoon for 40 minutes. It started with one question and ended with some questions related to my resume and projects.

1. Container With Most Water

Moderate
15m average time
90% success
0/80
Asked in companies
BNY MellonAmazonSAP Labs

Given a sequence of ‘N’ space-separated non-negative integers A[1],A[2],A[3],......A[i]…...A[n]. Where each number of the sequence represents the height of the line drawn at point 'i'. Hence on the cartesian plane, each line is drawn from coordinate ('i',0) to coordinate ('i', 'A[i]'), here ‘i’ ranges from 1 to ‘N’. Find two lines, which, together with the x-axis forms a container, such that the container contains the most area of water.

Note :
1. You can not slant the container i.e. the height of the water is equal to the minimum height of the two lines which define the container.

2. Do not print anything, you just need to return the area of the container with maximum water.
Example

water-diagram

For the above Diagram, the first red marked line is formed between coordinates (2,0) and (2,10), and the second red-marked line is formed between coordinates (5,0) and (5,9). The area of water contained between these two lines is (height* width) = (5-2)* 9 = 27, which is the maximum area contained between any two lines present on the plane. So in this case, we will return 3* 9=27.
Problem approach

This is a very standard skyline problem For any 2 buildings we would want either the distance between them to be maximum or the height of each of them. Keep 2 pointers on the array, one on the the first element one on the last and keep track of the ans for this pair of pointers. If the element at the first pointer index is smaller than the last one, shift the first pointer by 1 to its right, otherwise shift the last pointer to its left by 1. 
Repeat this process until the pointers meet at the same point.

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 - 1
5 rounds | 15 problems
Interviewed by Microsoft
4035 views
0 comments
0 upvotes
company logo
SDE - 1
5 rounds | 7 problems
Interviewed by Microsoft
2661 views
0 comments
0 upvotes
company logo
SDE - 1
1 rounds | 2 problems
Interviewed by Microsoft
7425 views
0 comments
0 upvotes
company logo
SDE - 1
4 rounds | 7 problems
Interviewed by Microsoft
1273 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Amazon
115097 views
24 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
35147 views
7 comments
0 upvotes
company logo
SDE - 1
3 rounds | 11 problems
Interviewed by Amazon
21830 views
4 comments
0 upvotes