top of page

most common microsoft coding interview questions

the 15 most asked questions in a microsoft Coding interview

Arrays

Arrays

Determine if the sum of two integers is equal to the 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.

â€‹

Set columns and rows as zeros

â€‹

Problem statement

â€‹

Given a two-dimensional array, if any element within is zero, make its whole row and column zero.

â€‹

â€‹

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.

â€‹

â€‹

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.

Your job is to write code to make a deep copy of the given linked list. Here, deep copy means that any operations on the original list (inserting, modifying and removing) should not affect the copied list.

â€‹

Trees

trees

Level order traversal of binary tree

â€‹

Problem statement

â€‹

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

â€‹

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.

â€‹

Strings

strings

Reverse words in a sentence

â€‹

Problem statement

â€‹

Reverse the order of words in a given sentence(an array of characters).

â€‹

Find all palindrome substrings

â€‹

Problem statement

â€‹

Given a string find all non-single letter substrings that are palindromes.

â€‹

Dynamic Programming

dynamic programming

Find maximum single sell profit

â€‹

Problem statement

â€‹

Given a list of daily stock prices (integers for simplicity), return the buy and sell prices for making the maximum profit. You need to maximize the single buy/sell profit. If you can't make any profit, try to minimize the loss.

â€‹

Math and Stats

Math and stats

Find the missing number in the array

â€‹

Problem statement

â€‹

You are given an array of positive numbers from 1 to n, such that all numbers from 1 to n are present except one number 'x'. We have to find 'x'. The input array is not sorted.

â€‹

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.

â€‹

Backtracking

backtracking

Regular expression matching

â€‹

Problem statement

â€‹

Given a text and a pattern, determine if the pattern matches with the text completely or not at all by using regular expression matching. For simplicity, assume that the pattern may contain 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.

â€‹

Graphs

Graphs

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.

â€‹

Sorting and Searching

sorting and searching

Closest meeting point

â€‹

Problem statement

â€‹

Given N people on an MxM grid, find the point that requires the least total distance covered by all people to meet at that point.

â€‹

Search for the given key in a 2d matrix

â€‹

Problem statement

â€‹

We are given a 2D 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.

â€‹

more interview prep?

We've partnered with Educative to bring you the best interview prep around. For more Microsoft interview tips, check out this guide to the top 26 Microsoft coding interview questions. For more data structure and algorithm practice, check out the link below.

Need help preparing for the interview?

â€‹

Check out the

written and reviewed by real hiring managers.

bottom of page