Microsoft Corporation
Proud winner of ABECA 2024 - AmbitionBox Employee Choice Awards
Filter interviews by
I was interviewed before May 2021.
Round duration - 60 Minutes
Round difficulty - Easy
Given a binary tree with 'N' nodes, your task is to print the nodes in spiral order traversal.
The binary tree is represented i...
Print nodes of a binary tree in spiral order traversal.
Use a queue to perform level order traversal of the binary tree.
Alternate between printing nodes from left to right and right to left at each level.
Handle null nodes represented by '-1' appropriately.
Example: For input '1 2 3 -1 -1 4 5 -1 -1 -1 -1', the output should be '1 3 2 4 5'.
Round duration - 60 Minutes
Round difficulty - Easy
You are given a list of N
strings called A
. Your task is to determine whether you can form a given target string by combining one or more strings from A
.
The strings from A
c...
Given a list of strings, determine if a target string can be formed by combining one or more strings from the list.
Iterate through all possible combinations of strings from the list to form the target string.
Use recursion to try different combinations of strings.
Check if the current combination forms the target string.
Return true if a valid combination is found, otherwise return false.
Round duration - 60 Minutes
Round difficulty - Easy
Design an elevator system for efficient vertical transportation.
Divide building into zones to optimize elevator usage.
Implement algorithms for efficient elevator scheduling.
Include safety features like emergency stop buttons and overload sensors.
Consider user interface for passengers to select floors and monitor elevator status.
Tip 1 : Never give up
Tip 2 : Practice
Tip 3 : Be positive
Tip 1 : Keep it short
Tip 2 : Highlight skills and achievements
I was interviewed before Sep 2020.
Round duration - 90 minutes
Round difficulty - Easy
Pretty easy questions.
You are provided with an array of integers ARR
of size N
and an integer K
. Your task is to find and return the K
-th smallest value present in the array. All elements...
Find the K-th smallest element in an array of distinct integers.
Sort the array and return the element at index K-1.
Use a min-heap to find the K-th smallest element efficiently.
Implement quickselect algorithm for optimal performance.
Round duration - 20 Minutes
Round difficulty - Easy
1 coding question
Given a string S
consisting only of digits from 0 to 9, your task is to find all potential IP addresses that can be formed from S
and list them in lexicographical order. I...
Given a string of digits, find all potential valid IP addresses that can be formed from it.
Split the string into four parts and check if each part is a valid IP segment (0-255).
Use backtracking to generate all possible combinations of valid IP addresses.
Ensure that the IP address does not contain leading zeroes.
Return the valid IP addresses in lexicographical order.
Round duration - 45 Minutes
Round difficulty - Easy
Total Discussion on OS concepts
Memory management in operating systems involves allocation, deallocation, and optimization of memory usage.
Memory allocation: OS allocates memory to processes based on their requirements.
Memory deallocation: OS frees up memory when it is no longer needed by a process.
Memory optimization: OS optimizes memory usage through techniques like paging, segmentation, and virtual memory.
Examples: Paging in which memory is divide...
Round duration - 45 Minutes
Round difficulty - Easy
Easy in office environment
Your task is to identify the position of the only '1' bit in the binary representation of a given non-negative integer N
. The representation contains exactly one '1' and the rest are...
Find the position of the lone '1' bit in the binary representation of a given non-negative integer.
Iterate through the bits of the integer to find the position of the lone '1'.
Use bitwise operations to check if there is exactly one '1' bit in the binary representation.
Return the position of the lone '1' or -1 if there isn't exactly one '1'.
Tip 1 : Do a good project.
Tip 2 : Master the topics you are preparing.
Tip 1 : Avoid writing things you do not know
Tip 2 : Follow a proper format for Resume.
I was interviewed before Sep 2020.
Round duration - 45 minutes
Round difficulty - Medium
It was an online round hosted on cocubes. It consisted of 3 coding questions only and the duration of the test was 45 mins.
The test link with a unique id and password was sent to the email 1 day prior to the test day. It consisted to platform specification, sample test etc.
On the day of test, we were given a time slot of 5pm - 11pm. We could attempt the test as per our comfort.
The instructions were pretty straightforward and we could attempt it from anywhere.
There were only 2 requirements. A webcam must be available. And a decent internet.
About the Platform.
In all of the problems base classes and code were disabled, we needed to implement only certain classes/ functions. Clipboard copy was blocked, tab switching was not allowed and rest the platform is very basic and simple.
Given two singly linked lists, each representing a positive number without leading zeros, your task is to add these two numbers. The result should be returned a...
Add two numbers represented by linked lists and return the sum as a linked list.
Traverse both linked lists simultaneously while keeping track of carry.
Create a new linked list to store the sum.
Handle cases where one linked list is longer than the other.
Update the next pointer of the current node to point to the new node with the sum.
Handle the carry if it exists after reaching the end of both linked lists.
Given an array 'ARR' of integers with length 'N', the task is to determine the sum of the subarray (including an empty subarray) that yields the maximum sum among al...
Find the maximum sum of a subarray in an array of integers.
Iterate through the array and keep track of the maximum sum subarray ending at each index.
Use Kadane's algorithm to efficiently find the maximum subarray sum.
Consider the case where all elements are negative, in which case the maximum sum would be the largest negative number.
Given a binary tree of integers, your task is to calculate the sum of all the leaf nodes which are present at the deepest level of the binary tree. If ...
Calculate the sum of leaf nodes at the deepest level of a binary tree.
Traverse the binary tree to find the deepest level.
Keep track of leaf nodes at the deepest level and calculate their sum.
Handle null nodes represented by -1.
Ensure the sum fits in a 32-bit integer.
Round duration - 60 minutes
Round difficulty - Hard
This round is known as the group fly round. After clearing the first round, we were called at the Microsoft Gurgaon office for the face to face interviews. Approximately, 60 students were there on the day I was called. I guess there were multiple days for multiple slots.
We all were divided into groups of 6-8 people and were called inside a round table room with 1 interviewer. This round consisted of 1 problem only to be discussed over with the interviewer. And the solutions to be written on pen paper.
The key here is to walk through the thought process and the steps with the interviewer. He will go around the table and will have discussion with each one of us and discuss about the pros, cons of the solutions.
It is advisable to ask as many questions as possible, to gather requirements and to be sure what are the expectations.
Round duration - 60 minutes
Round difficulty - Medium
This was the first face to face round.
It was held just after the group fly. From my group fly slot, 2/7 were selected.
The interviewer made me comfortable, we started informal talks about college and hobbies.
It kicked off with some basic discussion of the previous round problems, he had some questions about the encryption and security related stuff from payment scenario.
Then there were some behavioral questions and lastly there were a couple of whitepaper coding questions.
Given an integer N
, your task is to position N
queens on an N x N
chessboard in such a way that no two queens threaten each other.
A queen can attack other queens that are in t...
Position N queens on an N x N chessboard so that no two queens threaten each other.
Use backtracking to explore all possible configurations.
Keep track of rows, columns, and diagonals to ensure no two queens threaten each other.
Display all valid configurations found.
Given a binary tree, your task is to print the left view of the tree.
The input will be in level order form, with node values separated by a...
Print the left view of a binary tree given in level order form.
Traverse the tree level by level and print the first node of each level (leftmost node).
Use a queue to keep track of nodes at each level.
Time complexity should be O(n) where n is the number of nodes in the tree.
Round duration - 45 minutes
Round difficulty - Easy
This was the second face to face. Almost 50% students were selected from the first face to face round.
This was very straightforward round, a hectic day and it was already late by now.
The interviewer started with formal introduction and gave me 2 very basic problems to code.
This code consists of writing the entire code from scratch on whitepaper, with unit tests that can cover almost all scenarios. Some sample test cases were given by the interviewer at the end, to validate and dry run my solution.
Determine if a given Singly Linked List of integers forms a cycle or not.
A cycle occurs when a node's next
points back to a previous node in the list. This...
Detect if a singly linked list forms a cycle by checking if a node's next pointer points back to a previous node.
Traverse the linked list using two pointers, one moving one step at a time and the other moving two steps at a time.
If the two pointers meet at any point, there is a cycle in the linked list.
If one of the pointers reaches the end of the list (null), there is no cycle.
You are provided with a non-empty binary tree where each node has a non-negative integer value. Compute and return the maximum possib...
Find the maximum path sum between two leaves in a binary tree.
Traverse the binary tree to find the maximum path sum between two leaves.
Keep track of the maximum sum encountered during traversal.
Consider all possible paths that include leaf nodes.
Handle cases where there is only one leaf node or no leaf nodes.
Implement a recursive function to calculate the maximum path sum.
Round duration - 30 minutes
Round difficulty - Easy
This was the final round.
It was very late in the evening, around 10pm.
The interviewer here was one of the senior manager in the org (M2).
This kicked off with very informal conversations and introductions.
The interviewer was very engaging.
Tip 1 : Be solid with the basics of Ds, Algo. Good to have end to end projects which are hosted on cloud.
Tip 2 : Its always good to be presentable and have good communications skills
Tip 3 : Be honest, clear in approach and always walkthrough your thought process to the interviewer
Tip 1 : Mention your projects and experience at the top. Be clear on what was done, a brief on how it was done, language /tech stack involved. If possible try to host and make it accessible. You never know if you can present it with just one click.
Tip 2 : Choose a balance between, white spaces and text, it should be well indented, no grammatical errors.
Tip 3 : It takes less than 2 min to scan a resume. Don't mention things which are irrelevant.
What people are saying about Microsoft Corporation
I was interviewed before Sep 2020.
Round duration - 90 minutes
Round difficulty - Hard
Online coding contest, focus on DP and trees
In Ninjaland, a chess tournament is being organized with C
chess players attending. They will all stay in a hotel that has N
available rooms. Each player will choose one...
Assign rooms to chess players to maximize overall focus level by minimizing distance between rooms.
Sort the positions of rooms in ascending order.
Calculate the distances between adjacent rooms.
Select rooms with minimum distances to maximize overall focus level.
Round duration - 45 minutes
Round difficulty - Hard
It was conducted on the GHCI conference itself. It was held in a Microsoft interview room at the career fair of the conference. This was primarily based on my coding abilities and understanding how to optimise a solution
Given a string S
and a list wordList
containing N
distinct words, determine if each word in wordList
is present in S
. Return a boolean array where the value at index 'i' indi...
Given a string and a list of words, check if each word in the list is present in the string and return a boolean array.
Iterate through each word in the wordList and check if it is present in the string S.
Use a boolean array to store the presence of each word in the string.
Remember that the presence of a word is case sensitive.
Do not use built-in string-matching methods.
Return the boolean array without printing it.
Round duration - 30 minutes
Round difficulty - Medium
This was a system design round.
Round duration - 20 minutes
Round difficulty - Easy
This was the HR round and only typical HR questions were asked.
Tip 1 : Practice implementation of code end to end
Tip 2 : CV should have many projects and published paper to be shortlisted
Tip 3 : Focus on optimization
Tip 1 : Include projects in your resume.
Tip 2 : Keep resume of one page, but utilize the entire page efficiently
Microsoft Corporation interview questions for designations
I applied via Campus Placement
Get interview-ready with Top Microsoft Corporation Interview Questions
I applied via Campus Placement and was interviewed in Dec 2016. There were 6 interview rounds.
Merging two sorted linked lists and writing test cases.
Create a new linked list to store the merged list
Compare the first nodes of both lists and add the smaller one to the new list
Repeat until one of the lists is empty, then add the remaining nodes to the new list
Write test cases to cover all possible scenarios, including empty lists and lists of different lengths
WAP to check if binary tree is height-balanced and write testcases
A binary tree is height-balanced if the difference between the heights of its left and right subtrees is not more than 1
Use recursion to check if each subtree is height-balanced
Write testcases to cover all possible scenarios, including empty tree, single node tree, and unbalanced trees
Find the intersection point of two linked lists.
Traverse both lists and find their lengths.
Move the head of the longer list to make both lists equal in length.
Traverse both lists in parallel until the intersection point is found.
C code to print last n lines of a file given file pointer and integer n.
Use fseek() to move the file pointer to the end of the file
Count the number of newline characters encountered from the end of the file until n lines are found
Use fgets() to read and print the last n lines
Deadlock is a situation where two or more processes are unable to proceed due to a circular dependency on resources.
Deadlock occurs when two or more processes are waiting for resources held by each other.
Conditions for deadlock are mutual exclusion, hold and wait, no preemption, and circular wait.
Methods to prevent deadlock include resource allocation graph, banker's algorithm, and deadlock avoidance.
To prevent deadloc...
Use synchronization techniques like locks, semaphores, or mutexes to prevent multiple processes from accessing shared memory simultaneously.
Implementing a locking mechanism to ensure only one process can access the shared memory at a time.
Using semaphores to control access to the shared memory.
Using mutexes to ensure mutual exclusion and prevent race conditions.
Using atomic operations to ensure that memory operations a...
IPC stands for Inter-Process Communication. It is a mechanism that allows processes to communicate with each other.
Types of IPC include shared memory, message passing, and pipes.
Shared memory allows processes to share a portion of memory.
Message passing involves sending messages between processes.
Pipes are a unidirectional form of communication.
Shared memory is faster than message passing, but message passing is more r...
Designing an offline browser poses challenges such as data storage, synchronization, and user experience.
Ensuring efficient data storage and retrieval
Implementing synchronization with online content
Providing a seamless user experience with limited connectivity
Handling updates and changes to online content
Managing cache and memory usage
Dealing with security concerns
Handling different file types and formats
Data structure and code for BFS of N-ary tree
N-ary tree can be represented using a node class with a list of child nodes
BFS can be implemented using a queue data structure
Iterate through the queue and add child nodes to the queue
Pop the node from the queue and process it
Repeat until the queue is empty
Find node with maximum weight in a binary tree based on data and level of node
Calculate weight of each node based on data and level
Traverse the binary tree and keep track of node with maximum weight
Return the node with maximum weight
Program to check if a given number is a lucky number or not.
Create a function that takes an integer n as input
Initialize a variable count to 2
Loop through the sequence and delete every count-th element
Repeat the above step until the end of the sequence
If n is present in the final sequence, return true, else return false
Code to find inorder successor of given node in binary tree
Check if the given node has a right subtree, if yes then find the leftmost node in the right subtree
If the given node does not have a right subtree, then traverse up the tree until we reach a node which is the left child of its parent
If we reach the root and the given node is the rightmost node, then there is no inorder successor
Given an integer array, find all (a,b,c) such that a^2 + b^2 = c^2. Solution is O(n^2). Write code and testcases.
Use nested loops to iterate through all possible pairs of integers in the array
Check if the sum of squares of the two integers is a perfect square
If yes, add the triplet to the result list
Return the result list
Find height of binary tree without recursion
Use a stack to keep track of nodes
Iteratively traverse the tree and update height
Testcases: empty tree, single node tree, balanced tree, unbalanced tree
Count the number of occurrences of a given bit pattern in an integer.
Extract the n trailing bits from the pattern and create a mask with all other bits set to zero.
Use a sliding window approach to compare the extracted pattern with all possible n-bit sequences in the input integer.
Increment a counter every time the extracted pattern matches with a sequence in the input integer.
Given a binary tree, check if left and right subtrees are mirror images of each other.
Traverse the tree and compare left and right subtrees recursively.
Use a stack or queue to traverse the tree iteratively.
Check if the left subtree is a mirror image of the right subtree by comparing their values and structures.
Consider an empty tree as a mirror image of itself.
Find the longest repeating substring in a given string.
Create an array of all possible substrings of the given string.
Sort the array in lexicographic order.
Find the longest common prefix between adjacent strings.
Return the longest common prefix found.
If no repeating substring is found, return an empty string.
Pick a fruit from the basket containing both fruits and label the baskets accordingly.
Pick a fruit from the basket labelled 'apples and oranges'
If you pick an apple, label the basket containing only apples
If you pick an orange, label the basket containing only oranges
Label the remaining basket as containing both fruits
Escape from an intelligent lion at the circumference of a circular pond with given speeds.
Swim towards the circumference of the pond to make the lion run a longer distance.
Once the lion is at a considerable distance, get out of the pond and run in the opposite direction.
Use obstacles like trees or rocks to slow down the lion.
Try to confuse the lion by changing directions frequently.
Determining the result of string reversal and rotation operations using a reverse function.
The first operation reverses the first half and second operation reverses the second half of the string, resulting in a rotation of the string left k positions.
The third operation reverses the entire string, resulting in a reversal of the string.
Therefore, the correct answer is (b) Rotates the String left k positions.
Example: s =...
Relation between num and len in a given code snippet
The code recursively calls the function abc() twice for each character in the string
The printf() statement prints each character once
The number of '>' characters printed on the screen is equal to num
The length of the string is equal to len
The relation between num and len is num = 2^len - 1
Identifying which numbers cannot be accurately represented in binary.
Binary cannot accurately represent decimal fractions that do not have a power of 2 as their denominator.
Option a (0.1) and option e (0.590625) cannot be accurately represented in binary.
Option b (6.5) and option d (1.32) can be accurately represented in binary.
Option c (1/16) can be accurately represented in binary as 0.0001.
Additional processors required to execute a process in 150s with 40% sequential execution.
Process takes 300s on a single processor
40% of the process is sequential and doesn't require additional processors
Calculate the time taken by the remaining 60% of the process
Determine the speedup required to execute the remaining 60% in 150s
Calculate the number of additional processors required based on the speedup
Determining worst case time complexity of a code snippet with given time complexity of a function and array
The time complexity of the given code snippet is O(n)
The function f(m) is called only when a 0 is encountered in the array
The worst case time complexity is O(n)
The code snippet iterates through the entire array once
Increasing RAM improves CPU efficiency due to virtual memory and reduced page faults.
Increasing RAM allows for more data to be stored in memory, reducing the need for frequent access to slower storage devices.
Virtual memory allows the operating system to use hard disk space as if it were RAM, increasing the effective amount of memory available to the CPU.
Reducing page faults, which occur when the CPU needs to access da...
I applied via Campus Placement
Some of the top questions asked at the Microsoft Corporation Software Developer interview -
The duration of Microsoft Corporation Software Developer interview process can vary, but typically it takes about less than 2 weeks to complete.
based on 29 interviews
4 Interview rounds
based on 78 reviews
Rating in categories
Software Engineer
2k
salaries
| ₹0 L/yr - ₹0 L/yr |
Senior Software Engineer
1.1k
salaries
| ₹0 L/yr - ₹0 L/yr |
Software Engineer2
1k
salaries
| ₹0 L/yr - ₹0 L/yr |
Consultant
599
salaries
| ₹0 L/yr - ₹0 L/yr |
Support Engineer
552
salaries
| ₹0 L/yr - ₹0 L/yr |
Amazon
Deloitte
TCS