Home/Blog/Interview Prep/Top 26 coding questions to crack the Microsoft interview
Home/Blog/Interview Prep/Top 26 coding questions to crack the Microsoft interview

Top 26 coding questions to crack the Microsoft interview

May 29, 2024
14 min read

Aiming for a career at Microsoft is a worthy challenge given the company’s excellent track record for technological innovation, generous compensation packages, and flexible work-life balance.

As the largest and arguably most influential software company in the world, prospective applicants may find the technical interview process daunting. However, familiarizing yourself with the type of technical questions that will be presented to you and learning to recognize coding patterns will help you navigate these interviews with greater confidence.

We’ll start with an introduction to 26 common coding questions, move on to an overview of the complete interview process for software engineers, move on to frequently asked technical questions, and then wrap up with additional guidance and resources to maximize your chances of receiving an offer.

26 common coding questions#


As you go over each question, get into the habit of diagramming the problem before jumping straight to writing code. Breaking down a problem first gives you a chance to ask questions and get any important information you need to come up with the best possible solution. Take a moment to explain your thought process to yourself as if you were the interviewer.

Take some time to reflect on the efficiency of your solution, and try to see if you can make your answer more elegant by simplifying it.

Lastly, always remember to validate your solutions.

Alright, let’s dive in!

Arrays#

1. Find the missing number in a given array#

Problem Statement: Given an array of positive numbers ranging from 1 to n, such that all numbers from 1 to n are present except one number x, find x. Assume the input array is unsorted.

n = 8; x =6
n = 8; x =6

2. Determine if the sum of two integers is equal to a given value#

Problem Statement: Given an array of integers and a value, determine if there are any two integers in the array whose sum is equal to the given value. Return true if the sum exists, and false if it does not. Consider the following array and its target sums:

Check if the sum of any two numbers is equal to the target value
Check if the sum of any two numbers is equal to the target value

3. Set columns and rows as zeroes#

Problem Statement: Given a two-dimensional array, if any element within is zero, make its whole row and column zero. Consider the matrix below.

Given matrix
Given matrix

There are two zeros in the input matrix at positions (1,1) and (2,3). The output of this should be a matrix in which the first and second rows become zero and the first and third columns become zero. Below is the expected output matrix.

Expected output
Expected output

Linked Lists#

4. Add two integers#

Problem Statement: Given the head pointers of two linked lists where each linked list represents an integer number (each node is a digit), add them and return the resulting linked list. In the example below, the first node in a list represents the least significant digit.

Add two numbers represented by Linked List
Add two numbers represented by Linked List

5. Copy linked list with arbitrary pointer#

Problem Statement: You are given a linked list where the node has two pointers. The first is the regular next pointer. The second pointer is called arbitrary_pointer and it can point to any node in the linked list.

Here, deep copy means that any operations on the original list (inserting, modifying, and removing) should not affect the copied list.

Here’s an example of a linked list with arbitrary pointers connected.

Linked List with arbitrary pointers
Linked List with arbitrary pointers

6. Merge two sorted linked lists#

Problem Statement: Write a function that takes two sorted linked lists and merges them. The function should return a single, sorted list made from splicing the nodes of the first two lists together.

For example, if the first linked list is 1 -> 2 -> 4 and the second linked list is 3 -> 5 -> 6, then the output would be 1 -> 2 -> 3 -> 4 -> 5 -> 6

Trees#

7. Level order traversal of binary tree#

Problem Statement: Given the root of a binary tree, display the node values at each level.

Level order traversal of a binary tree
Level order traversal of a binary tree

The level order traversal for this binary tree looks like this:

100
50, 20
25, 75, 350

8. Connect all siblings#

Problem Statement: Connect the sibling pointer to the next node in the same level. The last node in each level should point to the first node of the next level in the tree.

Connect all siblings
Connect all siblings

9. Check a given binary tree for symmetry#

Problem Statement: Given a binary tree, write a program that will return true if the binary tree is a mirror image of itself, and false if it is not.

Symmetric tree
Symmetric tree

The correct output given this binary tree would be true because it is symmetrical.

Strings#

10. Reverse words in a sentence#

Problem Statement: Reverse the order of words in a given sentence.

Example: "sphinx of black quartz judge my vow" should output as "vow my judge quartz black of sphinx"

11. Find all palindrome substrings#

Problem Statement: Given a string, find all non-single letter substrings that are palindromes.

Example:

An string input of "poppopo" would return "pop", "opo", "oppo", and "poppop".

12. String segmentation#

Problem Statement: Given a dictionary of words and a large input string, find whether or not the input string can be completely segmented into the words of that dictionary.

Dynamic Programming#

13. Find the maximum single sell profit#

Problem Statement: Given a list of daily stock prices (integers for simplicity), return the buy and sell prices that will maximize the single buy/sell profit. If you can’t make any profit, try to minimize the loss.

For the below examples, buy (orange) and sell (green) prices for making a maximum profit are highlighted.

Stock buy and sell to maximize profit
Stock buy and sell to maximize profit

14. Length of longest subsequence#

Problem Statement: Given a one-dimensional integer array a of length n, find the length of the longest subsequence that increases before decreasing.

15. Find the longest path in a given matrix#

Problem Statement: Given an n*n matrix where all numbers are distinct, find the longest path starting from any cell such that all cells along the path increase in order by 1.

Math and Statistics#

16. Find the missing number in the array#

Problem Statement: Given an array of positive numbers ranging from 1 to n, such that all numbers from 1 to n are present except one number x, find x.

The input array is not sorted.

n = 8; x = 6
n = 8; x = 6

17. Find all sum combinations#

Problem Statement: Given a positive integer, target, print all possible combinations of positive integers that sum up to the target number.

For example, if we are given input ‘5’, these are the possible sum combinations.

1, 4
2, 3
1, 1, 3
1, 2, 2 
1, 1, 1, 2
1, 1, 1, 1, 1

The output will be in the form of a list of lists or an array of arrays. Each element in the list will be another list containing a possible sum combination.

18. Find the kth permutation#

Problem Statement: Given a set of n variables, find their kth permutation. Consider the following set of variables:

Find the kth permutation
Find the kth permutation

Backtracking#

19. Regular expression matching#

Problem Statement: Given a text and a pattern, determine if the pattern matches the text completely or not at all using regular expression matching. Assume the pattern contains only two operators: . and *. Operator * in the pattern means that the character preceding * may not appear or may appear any number of times in the text. Operator . matches with any character in the text exactly once.

Below is an example of a text and its matching and non-matching patterns.

20. Rat in a Maze#

Problem Statement: Consider a rat placed in a square n*n matrix at position (0, 0). Find all possible paths the rat can take to reach its destination (N-1, N-1) from its starting position.

The rat can move vertically and horizontally. Cells with a value of 1 can be traversed, while cells with a value of 0 cannot. The rat cannot visit a cell more than once.

21. Solve the Sudoku#

Problem Statement: Given a square matrix grid of 9*9 and configured to represent an incomplete Sudoku puzzle, find a solution that returns a true or false value depending on whether or not the Sudoku can be completed. If a solution is possible, your solution must also return the completed grid.

Graphs#

22. Clone a directed graph#

Problem Statement: Given the root node of a directed graph, clone this graph by creating its deep copy so that the cloned graph has the same vertices and edges as the original graph.

23. Conduct a Breadth-First Traversal of a given graph#

Problem Statement: Starting from the source node, traverse a given graph breadthwise to find the distance between the source node and node n.

24. Check if there’s a path from a source to its destination#

Problem Statement: Given a graph n*n with each cell containing a value of 0, 1, 2, or 3, return a true or false value depending on whether or not one can find a path from the source node to the destination node. Each graph will have one source node and one destination node. The graph can be traversed horizontally and vertically.

The cell containing a value of 0 is the source node. A value of 1 represents a wall; this node is impassable. A value of 2 represents a blank cell that can be traversed. A value of 3 represents the destination node.

25. Find the closest meeting point#

Problem Statement: Given n people on a square grid, find the point that requires the least total distance covered by all people to meet at that point.

A 5X5 grid with three people X, Y and Z.
A 5X5 grid with three people X, Y and Z.

26. Search for the given key in a two-dimensional matrix#

Problem Statement: We are given a two-dimensional array where all elements in any individual row or column are sorted. In such a matrix, we have to search or find the position of a given key.

Be prepared to go over#

If you have over 3 years of experience developing software, it is highly likely that you will be asked system design questions, which can be more open-ended.

To get an idea of what to expect from a system design interview, check out the System design interview questions.

Overview of the Microsoft hiring process#

The timeline for the entire process (from submitting your resume to receiving a job offer) takes approximately 1-2 months You are encouraged to use whatever mainstream programming language (e.g., C/C++ or Java) that you are most comfortable with to solve the technical questions.

Interviews#

  • Prescreening: A recruiter contacts you via email to schedule a 45-minute phone call. They will spend 15 minutes going over your resume and asking behavioral questions. You have the remaining 30 minutes to solve a coding question related to algorithms and data structures in a shared editor.
  • Phone interview: The recruiter contacts you within two weeks to schedule a phone interview with a senior developer or engineering manager. Information about potential topics that may be covered during this phone interview will be provided in advance.
  • On-site or virtual interview: After passing the phone interview, you will be invited to participate in 4-5 rounds of interviews either in-person at the Microsoft campus or virtually. Each round is an hour long and will be conducted by two members of the team you’re looking to join. These rounds will have both behavioral and technical questions.
  • Lunch interview: Halfway through the rounds, you will be taken out to lunch for a more casual conversation. This will take place on the Microsoft campus, or off-campus at a restaurant.
  • Final interview of the day: The last round will be conducted by an AS-AP (As-Appropriate) who will have the final say in hiring you.
  • HR interview: The hiring manager will go over any remaining behavioral or technical questions not covered in the previous rounds of interviews, make an offer, and discuss compensation.

How to prepare for the interview#

Microsoft develops a holistic view of you as a candidate using competency-based questioning in addition to your resume. They want candidates with strong technical skills that align well with the company values.

Step 1: Update your resume#

The first thing you want to do is to make sure your resume and LinkedIn profile are up to date. Be very specific, and use deliverables and metrics whenever possible.

Next, you’ll want to look at your resume in the context of the Microsoft Core Competencies. Consider how specific projects or experiences can be tied into different Core Competencies, and update them to reflect ways in which you have prioritized these values in your work.

Step 2: The 12-week interview prep roadmap#

To fully prepare yourself for the coding interview, we strongly suggest that you take three months to go over technical concepts and practice solving interview questions. Using an interview prep roadmap is a great way to keep track of your progress, and break down what you need to learn.

You can use our Definitive Interview Prep Roadmap to make sure you’re hitting all of the important topics that might be covered during coding interviews.

  • Week 0 - What programming language should you use?

  • Week 1 - Brush up on your chosen programming language.

  • Weeks 2 & 3 - Data structures and algorithms.

  • Weeks 4 & 5 - Practice simple data structures and algorithmic challenges

  • Weeks 6, 7 & 8 - Dive into more complex coding interview problems

  • Weeks 9 & 10 - System design interviews

  • Week 11 - OS and concurrency concepts

  • Week 12 - Object-oriented design interviews

Step 3: Prepare for the behavioral interview#

Behavioral interview questions typically fall into one of three categories:

  • Past experiences

  • Hypothetical situations

  • Values-based questions

Behavioral interviews help interviewers decide if you’re someone they would want to work with. Reflect on how you react to positive situations or conflicts in a professional setting, and be honest about your past experiences. Essentially, be your authentic self.

Don’t be afraid to bring your unique perspective to the table. Go beyond just answering questions. Really listen and respond to your interviewers. Show them that you’re engaged and tuned into the conversation you’re having with them.

The most important thing to keep in mind for any behavioral interview is that your interviewers want to hire you. If you’re enthusiastic about the technology you’ll be working with, don’t be afraid to show it!

If you want to brush up on behavioral interview questions, then check out How to prepare for the Behavioral Interview to learn more about what interviewers are looking for, and how you can develop the kind of structured responses that impress them.

You can also read up about the key attributes that define the culture at Microsoft.

Microsoft Software Engineer Interview#

According to research, less than 2% of candidates pass through all rounds of the Microsoft software engineer interview process. Although Microsoft was one of the first companies to exclude tough brain teasers from their coding interviews, passing through is still pretty challenging. You need expert guidance and the right practice questions to upscale your interview skills.

Microsoft software engineer interviews usually consist of 5-6 rounds on the same day. Microsoft, being one of the premier technology giants, wants to ensure that they hire the best and brightest minds in the industry. That’s why a major part of the interview process consists of technical questions to analyze your problem-solving abilities and critical thinking. We have mentioned the most frequently asked questions during a Microsoft software engineer interview. For a detailed coding interview prep, you can try Educative-99 and the exclusive interview prep courses that Educative offers.

Microsoft’s multi-faceted approach ensures that candidates can tackle intricate technical challenges while also demonstrating adaptability, teamwork, and alignment with Microsoft’s values and culture. This dual emphasis paves the way for engineers who are adept both at coding and co-creating in a dynamic environment.

Wrapping up and next steps#

Now that you’re more familiar with the Microsoft interview process, it’s time to make a plan and put it into action! The best candidates come fully prepared, so it’s important to exercise due diligence. We’ve put together an extensive course that will help you quickly identify any gaps in your knowledge, test your skills, and practice using a live, in-browser coding environment.

You can visit our Decode the Coding Interview library. The Decode series exposes you to some of the most frequently asked questions at tech companies and helps solidify your knowledge by contextualizing these problems in real-world applications.

Happy learning!

Educative Unlimited#

If you like our content, consider signing up for Educative Unlimited today!

Frequently Asked Questions

How do I prepare for a Microsoft interview?

The preparation depends on the position for which you’re applying. Educative-99 is a great resource to practice your coding skills. Curated by industry experts, Educative-99 includes the most commonly asked technical questions to help you prepare for your Microsoft interview.

What kind of questions are asked in a Microsoft interview?


  

Free Resources