Microsoft Corporation
Proud winner of ABECA 2024 - AmbitionBox Employee Choice Awards
Filter interviews by
Find the nth element in a tribonacci series.
Use recursion to solve the problem.
Handle base cases for n=0, n=1, and n=2.
For n>2, use the formula t(n)=t(n-1)+t(n-2)+t(n-3).
Return the value of t(n) for the given n.
Given three sides of a triangle, determine its nature.
Check if any two sides are equal to determine if it's isosceles
Check if all three sides are equal to determine if it's equilateral
Use Pythagoras theorem to check if it's right angled
If none of the above, it's a scalene triangle
I have used Microsoft Office, Windows OS, Visual Studio, and Azure. I want to join Microsoft because of its innovative culture and impact on the tech industry.
I have used Microsoft Office for word processing, spreadsheet management, and presentation creation.
I have used Windows OS for personal and professional use.
I have used Visual Studio for software development.
I have used Azure for cloud computing and hosting.
I wan...
Synchronization is the coordination of multiple threads to ensure they access shared resources in a controlled manner.
Synchronization is important in multi-threaded programming to prevent race conditions and ensure data consistency.
It involves acquiring and releasing locks, using semaphores, mutexes, or other synchronization mechanisms.
Examples include using synchronized blocks in Java or pthread_mutex_lock in C to pro...
The longest code I wrote was a complex web application with over 10,000 lines of code. The toughest code I wrote was a machine learning algorithm for image recognition.
Longest code: Complex web application with over 10,000 lines of code
Toughest code: Machine learning algorithm for image recognition
Connect each node to its immediate right node on the same level in a binary tree.
Use level order traversal to connect nodes on the same level.
Use a queue to keep track of nodes at each level.
Update the 'next' pointer of each node to point to the next node in the queue.
A dictionary in a phone is implemented using data structures like hash tables or tries to efficiently store and retrieve words and their meanings.
A dictionary app on a phone may use a hash table to store words as keys and their meanings as values.
The app can use a trie data structure to efficiently search for words and provide autocomplete suggestions.
The dictionary may also include features like word pronunciation, sy...
What people are saying about Microsoft Corporation
Code a run length encoding algorithm to compress a text string in place.
Use a loop to iterate through the string and count consecutive characters
Create a new string to store the compressed version of the original string
Add the character and its count to the new string
Compare the length of the new string to the original string to determine if compression was successful
Print the leftmost node at the same level as a given node in a binary search tree.
Traverse the tree level by level using BFS
Keep track of the leftmost node at each level
Return the leftmost node at the level of the given node
If the given node is not found, return null
Search for an element in a rotated sorted array in sublinear time.
Use binary search to find the pivot point where the array is rotated.
Determine which half of the array the target element is in.
Perform binary search on the appropriate half of the array to find the target element.
Time complexity is O(log n).
Given an amount and coin denominations, find the smallest no of coins to form the amount.
Use dynamic programming to solve the problem
Create a table to store the minimum number of coins required for each amount
Iterate through the denominations and update the table accordingly
Return the minimum number of coins required for the given amount
Move all distinct elements of an array to the top in any order.
Create a new array to store distinct elements
Loop through the original array and check if element is already in new array
If not, add it to the new array and remove it from the original array
Concatenate the new array with the remaining elements of the original array
There can be multiple such elements in the matrix.
Multiple elements can be max in their row and min in their col
The function should return all such elements
The elements can be in different rows and columns
Microsoft Corporation interview questions for popular designations
Get interview-ready with Top Microsoft Corporation Interview Questions
The question asks to add two numbers represented as linked lists and return the sum as a linked list.
Traverse both linked lists simultaneously, adding the corresponding digits and carrying over the carry.
Create a new linked list to store the sum digits.
Handle cases where one linked list is longer than the other.
Consider cases where the sum has an additional carry digit at the end.
Count the number of times a substring appears in a string.
Use a loop to iterate through the string and check for the substring at each index.
Use the count() method to count the number of occurrences of the substring.
Consider using regular expressions to find all occurrences of the substring.
Handle edge cases such as empty strings or substrings.
The task is to compress a given string by replacing consecutive repeated characters with the character followed by the count of repetitions.
Iterate through the string and keep track of the current character and its count.
If the next character is the same as the current character, increment the count.
If the next character is different, append the current character and its count to the result string.
Return the compressed
Find the leftmost node in the same level as a given node in a binary tree.
Traverse the tree level by level using BFS
For each level, keep track of the leftmost node encountered
Return the leftmost node in the level of the given node
Find the nth largest number in a binary tree
Traverse the tree in-order and store the values in an array
Return the (n-1)th index of the sorted array in descending order
Use a max heap to keep track of the largest n elements
Insert an element into a sorted circular linked list.
Find the correct position to insert the element based on its value
Update the pointers of the previous and next nodes to include the new node
Handle special cases such as inserting at the beginning or end of the list
Example: Inserting 5 into a list with values 1, 3, 4, 6, 7 would result in 1, 3, 4, 5, 6, 7
Prove that given 5 points in a plane, there will be at least two points such that their midpoint is an integer.
Consider the x and y coordinates of the 5 points.
If any two points have the same x and y coordinates, their midpoint will be an integer.
If not, consider the differences between the x and y coordinates of each pair of points.
If any two pairs have differences that are both even or both odd, their midpoints will ...
Use exponentiation by squaring algorithm to find nth power of a number in shortest computational time.
Use recursion to divide the power by 2 and multiply the base accordingly
If power is odd, multiply the base with the result of recursive call
If power is negative, take reciprocal of base and make power positive
Handle edge cases like power=0 and base=0 or 1
Time complexity is O(log n)
The function ring() calculates the number of blocks of both types based on sensor state changes.
Create a variable to keep track of the number of 49 cm blocks
Create another variable to keep track of the number of 50 cm blocks
Initialize both variables to 0
Whenever the sensor changes state, increment the corresponding block variable
Return the count of both block types as an array of strings
The given linked list needs to be inverted in pairs of two nodes.
Iterate through the linked list, swapping every two adjacent nodes.
Keep track of the previous node to update the next pointers correctly.
Handle the edge cases of odd number of nodes or empty list.
Add two numbers stored in linked lists and return the sum in a linked list.
Traverse both linked lists and add the digits at each node while keeping track of carry.
Create a new linked list to store the sum digits.
Handle cases where one linked list is longer than the other.
Handle cases where the sum of the last digits results in a carry.
Return the new linked list with the sum digits.
Count the number of times a substring appears in a string.
Use a loop to iterate through the string and check for the substring at each index.
Use the count() method to count the number of occurrences of the substring.
Consider using regular expressions to find all occurrences of the substring.
Handle edge cases such as empty strings or substrings.
Compress a string by replacing consecutive characters with their count.
Iterate through the string and count consecutive characters.
Append the character and its count to a new string.
Handle edge cases like single characters.
Find the leftmost node in the same level as a given node in a binary tree.
Traverse the tree level by level using BFS
For each level, keep track of the leftmost node encountered
Return the leftmost node at the same level as the given node
Find the nth largest number in a binary tree
Traverse the tree in-order and store the values in an array
Return the (n-1)th index of the sorted array in descending order
Use a max heap to keep track of the largest n elements
Prove that given 5 points in a plane, there will be at least two points such that their midpoint is an integer.
Consider the x and y coordinates of the 5 points.
If any two points have the same x and y coordinates, their midpoint will be an integer.
If not, consider the differences between the x and y coordinates of each pair of points.
If any two pairs have the same differences, their midpoints will be integers.
Otherwise,...
Use exponentiation by squaring algorithm to find nth power of a number in shortest computational time.
Use recursion to divide the power by 2 and multiply the base accordingly
If power is odd, multiply the base with the result of recursive call
If power is negative, take reciprocal of base and make power positive
Handle edge cases like power=0 and base=0 or 1
Time complexity is O(log n)
Function to calculate number of 49cm and 50cm wood blocks using two sensors 50cm apart.
Create a variable to store the count of 49cm blocks and another for 50cm blocks
Use a loop to continuously check the state of the sensors and increment the respective block count
Call the ring() function whenever the state of the sensors change
Return the count of both types of blocks
Invert every two nodes in a linked list.
Create a temporary node to store the next node
Swap the positions of the current and next nodes
Set the current node's next to the temporary node
Move to the next pair of nodes and repeat until end of list
Function to check if min^2 < max condition is satisfied in an array of strings
Convert array elements to integers
Find the minimum and maximum values in the array
Check if min^2 < max, return 1 if true, 0 if false
The number of delfirst() operations needed to satisfy a condition in an array.
The number of delfirst() operations needed is equal to the index of the first element that satisfies the condition.
For example, if the array is ['apple', 'banana', 'cherry'] and the condition is to have the first element start with 'b', then 1 delfirst() operation is needed to get ['banana', 'cherry'].
To satisfy the condition 1, only one operation is needed - either delfirst() or dellast().
To satisfy the condition 1, you can either use delfirst() or dellast() operation once.
For example, if the array is ['a', 'b', 'c', 'd'], you can use delfirst() operation to get ['b', 'c', 'd'] or dellast() operation to get ['a', 'b', 'c'].
Sort a large int array in the range 1-10.
Use counting sort algorithm for efficient sorting.
Create a count array to store the frequency of each number.
Iterate through the count array to reconstruct the sorted array.
Given multiple rectangles on a screen, find the smallest rectangle enclosing a user-clicked point.
Iterate through each rectangle and check if the clicked point lies within its boundaries
Keep track of the smallest enclosing rectangle found so far
Return the smallest enclosing rectangle
The poke feature in Facebook allows users to send a quick and playful gesture to get someone's attention.
Users can poke their friends to say hello or get their attention.
Poking someone sends them a notification.
Pokes can be sent back and forth between friends.
Pokes can be used as a fun way to interact with friends without sending a message.
Merge N large files containing operations sorted by name for an address book
Read each file and merge the operations based on name
Use a sorting algorithm to maintain the order while merging
Handle duplicate operations for the same name
Consider memory constraints while merging large files
Common in 2 threads: share same memory space, variables, code, and resources. Difference: have separate execution paths and stack.
Common: share same memory space, variables, code, and resources
Difference: have separate execution paths and stack
Example: Two threads in a process sharing access to a global variable
Communication between 2 processes can be achieved through inter-process communication mechanisms.
Use pipes to establish a unidirectional communication channel between processes
Use sockets for bidirectional communication over a network
Shared memory can be used to exchange data between processes
Message queues provide a way to send and receive messages between processes
Signals can be used to notify and communicate between
Check if 4 selected boxes in a 2-D array of chars are continuous in the 3x3 sub array surrounding each box.
Iterate through the selected boxes and check if they are within the 3x3 sub array of each box.
Consider edge cases where the selected boxes are at the boundaries of the array.
Example: If the selected boxes are (1,1), (1,2), (2,1), (2,2), they form a continuous 2x2 sub array.
Some of the top questions asked at the Microsoft Corporation interview -
The duration of Microsoft Corporation interview process can vary, but typically it takes about less than 2 weeks to complete.
based on 375 interviews
Interview experience
based on 1.7k reviews
Rating in categories
Software Engineer
1.6k
salaries
| ₹16 L/yr - ₹50 L/yr |
Senior Software Engineer
1.1k
salaries
| ₹25 L/yr - ₹96 L/yr |
Software Engineer2
1k
salaries
| ₹20 L/yr - ₹72 L/yr |
Software Developer
762
salaries
| ₹14 L/yr - ₹50.4 L/yr |
Consultant
600
salaries
| ₹13 L/yr - ₹36.7 L/yr |
Amazon
Deloitte
TCS