Microsoft Interview Questions for Software Engineers
Microsoft hires software engineers in India (mainly in Hyderabad, Bengaluru and Noida) through an online coding test followed by three or four interview rounds of coding, design and problem-solving, often ending with an "as appropriate" (AA) round with a senior manager. These Microsoft interview questions cover the coding problems, design questions and behavioural questions asked most, with model answers and code.
18 questions · Updated
Reading answers is not the same as saying them.Practise Microsoft questions out loud and get a score, what you missed and a model answer for each one.
Practise linked lists, trees, matrices and strings thoroughly: Microsoft interviews ask many classic problems on these, often with tricky edge cases.
Write complete, compilable code and walk through test cases yourself, including empty input, one element and very large values.
Revise OOP, design patterns and SOLID principles, operating systems (threads, deadlock, memory) and low-level design, which Microsoft asks more than many other companies.
Prepare for the AA round: a mix of a harder problem, a design discussion and questions about your motivation, growth mindset and teamwork.
Learn about Microsoft's products and culture, especially its focus on a growth mindset, and be ready for "Why Microsoft?"
Coding round (DSA)
Data structures and algorithms problems solved live, usually in 45 minutes each. Explain your approach before you code.
1. Reverse a singly linked list.
Answer flow · 5 steps
1
Walk through the list with three pointers: previous, current and next.
2
At each step, save next, point current back to previous, then move previous and current forward.
3
When current becomes null, previous is the new head.
4
This is O(n) time and O(1) space.
5
Be ready to also write the recursive version and explain why it uses O(n) stack space.
def reverse_list(head):
prev, cur = None, head
while cur:
nxt = cur.next
cur.next = prev
prev, cur = cur, nxt
return prev
2. Detect whether a linked list has a cycle, and find where it begins.
Answer flow · 4 steps
1
Use Floyd's algorithm: a slow pointer moves one step and a fast pointer two steps.
2
If they meet, there is a cycle.
3
To find its start, move one pointer back to the head and advance both one step at a time; they meet at the start of the cycle.
4
This is O(n) time and O(1) space, better than storing visited nodes in a set.
def cycle_start(head):
slow = fast = head
while fast and fast.next:
slow, fast = slow.next, fast.next.next
if slow is fast:
slow = head
while slow is not fast:
slow, fast = slow.next, fast.next
return slow
return None
3. Check whether a binary tree is a valid binary search tree.
Answer flow · 5 steps
1
A common mistake is only comparing each node with its children.
2
Instead, pass down a valid range: every node in the left subtree must be less than the current node and every node in the right subtree greater.
3
Recurse with updated bounds.
4
Alternatively, an in-order traversal of a valid BST must be strictly increasing.
5
Time is O(n).
def is_valid_bst(node, low=float("-inf"), high=float("inf")):
if not node:
return True
if not (low < node.val < high):
return False
return (is_valid_bst(node.left, low, node.val) and
is_valid_bst(node.right, node.val, high))
4. Print a matrix in spiral order.
Answer flow · 4 steps
1
Keep four boundaries: top, bottom, left and right.
2
Traverse the top row left to right, the right column top to bottom, the bottom row right to left and the left column bottom to top, shrinking the boundary after each.
3
Check that the boundaries have not crossed before the last two directions, to handle single rows or columns.
4
Time is O(rows × columns).
5. Rotate an n × n matrix by 90 degrees clockwise in place.
Answer flow · 3 steps
1
Transpose the matrix (swap matrix[i][j] with matrix[j][i] for j greater than i), then reverse each row.
2
Both steps work in place, so extra space is O(1) and time is O(n²).
3
For anticlockwise rotation, transpose and then reverse each column.
def rotate(m):
n = len(m)
for i in range(n):
for j in range(i + 1, n):
m[i][j], m[j][i] = m[j][i], m[i][j]
for row in m:
row.reverse()
6. Search for a target in a sorted array that has been rotated.
Answer flow · 6 steps
1
Use a modified binary search.
2
At each step, one half of the range is sorted.
3
If the left half is sorted and the target lies within it, search left; otherwise search right.
4
Do the same check when the right half is sorted.
5
This keeps O(log n) time.
6
Handle duplicates as a follow-up, where the worst case becomes O(n).
7. Merge k sorted linked lists.
Answer flow · 4 steps
1
Push the head of each list into a min-heap keyed by value.
2
Repeatedly pop the smallest node, append it to the result and push its next node.
3
Each of the N total nodes is pushed and popped once, so the time is O(N log k).
4
A divide-and-conquer approach that merges lists in pairs has the same complexity.
8. Print the level order traversal of a binary tree.
Answer flow · 3 steps
1
Use BFS with a queue.
2
Start with the root; for each level, record the queue's current size, pop that many nodes, add their values to the level list and push their children.
3
Variants Microsoft asks include zigzag order, right side view and level averages, which are all small changes to this pattern.
System design and technical depth
Design questions and computer science fundamentals. Low-level design for freshers, high-level design for experienced engineers.
9. Design the classes for an elevator system (low-level design).
Answer flow · 3 steps
1
Classes: ElevatorSystem (manages elevators and dispatches requests), Elevator (current floor, direction, state, a queue of stops), Request (floor, direction) and a Scheduler strategy interface.
2
A common scheduling rule is to serve all requests in the current direction before reversing (the SCAN algorithm).
3
Discuss states with a state machine (idle, moving up, moving down, doors open), handling emergency stops and how the dispatcher picks the best elevator.
10. How would you design a file sync service like OneDrive?
Answer flow · 4 steps
1
Split files into chunks and store them in object storage, identified by content hashes so identical chunks are stored once.
2
A metadata service tracks files, versions and which chunks make up each version.
3
Clients watch for local changes, upload only changed chunks, and receive notifications of remote changes through long polling or websockets.
4
Handle conflicts when the same file is edited on two devices by keeping both versions and letting the user choose.
11. Explain the SOLID principles.
Answer flow · 5 steps
1
Single responsibility: a class should have one reason to change.
2
Open/closed: open for extension, closed for modification, such as adding a new payment type without editing existing code.
3
Liskov substitution: subclasses must work wherever the parent class is expected.
4
Interface segregation: prefer small, specific interfaces to one large one.
5
Dependency inversion: depend on abstractions, not concrete classes, which makes code easier to test and change.
12. What are the singleton, factory and observer design patterns?
Answer flow · 3 steps
1
Singleton ensures a class has only one instance, such as a configuration manager; it must be made thread-safe and is often overused.
2
Factory creates objects without the caller knowing the exact class, such as a NotificationFactory returning an EmailNotifier or SmsNotifier.
3
Observer lets objects subscribe to events from a subject and be notified on changes, as in UI event handlers or publish-subscribe systems.
13. What is the difference between a mutex and a semaphore?
Answer flow · 3 steps
1
A mutex is a lock that allows only one thread into a critical section at a time, and only the thread that locked it should unlock it.
2
A semaphore is a counter that allows up to N threads at once, such as limiting connections to a database pool; a binary semaphore behaves like a mutex but has no ownership.
3
Both prevent race conditions; misuse of either can cause deadlocks.
Behavioural and AA round
Questions about your past work and how you behave in a team. Answer with real stories using the STAR method.
14. Why Microsoft?
Be specific: "Microsoft builds products used by billions, from Windows and Office to Azure and GitHub, so the engineering challenges are huge in scale. I also like its focus on a growth mindset and on accessibility, and its investment in AI through Azure and Copilot is where I want to grow." Mention a Microsoft product or technology you have actually used.
15. Tell me about a time you learned from a failure. (Growth mindset)
Answer flow · 4 steps
1
Microsoft's culture is built on a growth mindset, so show learning, not perfection.
2
For example: "My first hackathon project crashed during the demo because I had not tested on the judges' network setup.
3
Since then I always test in a production-like environment and prepare a fallback.
4
In the next hackathon our demo ran smoothly, and we placed in the top three."
16. Tell me about the most challenging project you have worked on.
Answer flow · 3 steps
1
Pick a technically challenging project, explain the hardest problem, what you tried and the result.
2
The AA interviewer may go very deep into its design, so choose a project you know inside out.
3
Mention what you would do differently now, which shows reflection.
17. How do you handle a disagreement with a teammate about a technical approach?
Show respect and a focus on outcomes: "I make sure I understand their reasoning, share mine with data or a quick prototype, and look for criteria we both agree on, such as performance or maintainability. If we still disagree, we involve the tech lead and I fully support the final decision." Microsoft values collaboration over winning arguments.
18. Tell me about a time you made something more accessible or inclusive.
Answer flow · 3 steps
1
Microsoft places strong emphasis on accessibility.
2
For example: "In our college event website, I added keyboard navigation, alt text and better colour contrast after a classmate with low vision said the site was hard to use.
3
It took a day and made the site usable for everyone." If you have no example, explain how you would consider accessibility in your work.
Ready to test yourself?Pick your topics and level, answer by voice or text, and get instant feedback. Free.
Company names are trademarks of their respective owners. Interview Ready is an independent practice site and is not affiliated with or endorsed by any company listed here.