Microsoft interview prep

Practice 30 problems from community-reported Microsoft interviews.

Ranked problems

30 problems
Microsoft interview prep, ordered by rank
ProblemDifficultyCompany lists
Hash tables

Find the indices of two different elements in an array whose values add up to a given target.

On the Amazon, Google, Microsoft, Meta, Samsung, Tekion, IBM, Oracle, J.P. Morgan, Morgan Stanley lists.

Try [2, 7, 11, 15] with a target of 9.

Reveal the indices

[0, 1] points to 2 and 7.

Easy
Linked lists

Two linked lists hold the digits of two numbers in reverse order. Return their sum in the same format.

On the Amazon, Google, Microsoft, Meta lists.

Medium
Strings

Return the longest contiguous part of a string that reads the same forward and backward.

On the Amazon, Google, Microsoft, Meta, Tekion, IBM, Oracle, J.P. Morgan lists.

Medium
Two pointers

Find every distinct triple of values that adds up to zero, using three different positions in the array.

On the Amazon, Google, Microsoft, Meta, Samsung, Oracle, Morgan Stanley lists.

Medium
Sliding window

Find the length of the longest contiguous stretch of a string in which no character appears twice.

On the Amazon, Google, Microsoft, Meta, Tekion, IBM, Oracle, J.P. Morgan, Morgan Stanley lists.

Medium
Prefix sums

Count how many nonempty contiguous parts of an integer array have a sum of exactly k.

On the Amazon, Google, Microsoft, Meta, IBM, J.P. Morgan lists.

Medium
Arrays

Given daily prices, find the best profit from buying once and selling on a later day. Return zero if no trade makes money.

On the Amazon, Google, Microsoft, Meta, IBM, J.P. Morgan, Morgan Stanley lists.

Easy
Two pointers

Compact a sorted array in place so each distinct value appears once at the front, then return the number of distinct values.

On the Google, Microsoft, Meta, Morgan Stanley lists.

Easy
Stacks

Check whether a string of round, square, and curly brackets closes every opening bracket in the correct order.

On the Amazon, Google, Microsoft, Meta, IBM, Oracle lists.

Easy
Two pointers

Choose two vertical lines that, together with the x-axis, can hold the greatest area of water.

On the Amazon, Google, Microsoft, Meta, IBM, Oracle lists.

Medium
Strings

Find the longest starting sequence of characters shared by every string in a list.

On the Amazon, Google, Microsoft, Meta, IBM lists.

Easy
Two pointers

Given a row of unit-width bars of different heights, calculate how much rainwater settles between them.

On the Amazon, Google, Microsoft, Meta, Samsung, Tekion lists.

Hard
Dynamic programming

Find the largest sum you can make by taking a nonempty, contiguous part of an array.

On the Amazon, Google, Microsoft, Meta, Tekion, Oracle lists.

Medium
Binary search

Find the median of two sorted arrays in logarithmic time relative to their combined length.

On the Amazon, Google, Microsoft, Meta lists.

Hard
Data structure design

Design a fixed-capacity cache with constant-time reads and writes. When it fills up, evict the least recently used key.

On the Amazon, Microsoft, Samsung, Oracle, J.P. Morgan, Morgan Stanley lists.

Medium
Hash tables

Find how many values form the longest run of consecutive integers in an unsorted array, in linear time.

On the Amazon, Google, Microsoft lists.

Medium
Monotonic queue

Slide a window of k elements across an array one position at a time and return the largest value in each window.

On the Microsoft, Oracle, J.P. Morgan lists.

Hard
Math

Decide whether the decimal digits of an integer read the same from either end.

On the Amazon, Google, Microsoft, Meta, Morgan Stanley lists.

Easy
Intervals

Combine overlapping intervals and return a list that covers the same ranges without overlaps.

On the Amazon, Microsoft, IBM, Oracle, J.P. Morgan, Morgan Stanley lists.

Medium
Dynamic programming

Choose houses along a street to maximize the money collected, with no two neighboring houses selected.

On the Microsoft list.

Medium
Strings

Read a Roman numeral and compute its integer value, accounting for smaller symbols that precede larger ones.

On the Google, Microsoft, IBM lists.

Easy
Backtracking

List the strings a sequence of digits from 2 to 9 could spell using a telephone keypad.

On the Microsoft, Tekion lists.

Medium
Two pointers

Move every zero to the end of an array in place while keeping the other values in their original order.

On the Microsoft, Meta lists.

Easy
Arrays

Rearrange the numbers in place into the next lexicographic order. If already last, wrap to the first ordering.

On the Microsoft, Meta lists.

Medium
Dynamic programming

Count the different ways to reach the top of a staircase if each move climbs one or two steps.

On the Google, Microsoft lists.

Easy
Graph traversal

Count the connected patches of land in a grid. Cells connect horizontally or vertically.

On the Amazon, Microsoft, Samsung, Oracle lists.

Medium
Hash tables

Decide whether two strings contain exactly the same characters with the same multiplicities.

On the Google, Microsoft, Meta, IBM, Oracle lists.

Easy
Backtracking

Generate every subset of a list of distinct numbers, including the empty set.

On the Microsoft, Meta lists.

Medium
Binary search

Search a matrix whose rows are sorted and whose next row starts above the previous row’s largest value. Use logarithmic time.

On the Microsoft list.

Medium
Sliding window

Find the shortest substring that contains all the target letters, including repeated letters. Return an empty string if none qualifies.

On the Microsoft list.

Hard
How are questions ranked?

Company lists follow community-reported interview frequency. Ties keep the source order. Where a list uses two sources, we keep the first list’s ranks and fill the remaining places with the highest-ranked distinct problems from the second.

Across companies, first place earns 30 points and each subsequent rank earns one fewer. We add each problem’s points and break ties alphabetically.