Technical Microsoft Interview Questions

Imagine you have eight balls, each of the same size.

One of the balls weights slightly more than the other seven.

Using a balance, find the heavier ball using only two weighings.

Write a function that takes as input a sorted array and modifies the array to compact it, removing duplicates. Also return the new length of the array.

Notes: The input array might be very large.

For example:

  • input array = [1, 3, 7, 7, 8, 9, 9, 9, 10]
  • transformed array = [1, 3, 7, 8, 9, 10]
  • size = 6

Express the following table as a static structure, and write a function, find_routes(source, destination) that efficiently outputs all possible routes.

Source  | Dest
~~~~~~    ~~~~
Seattle | LA
LA      | Florida
LA      | Maine
Florida | Seattle
Seattle | Florida

The solution for find_routes('Seattle', 'Florida') should be [Seattle -> Florida, Seattle -> LA -> Florida]

Imagine a bear walks the following paths:

  1. South one mile
  2. Left turn
  3. East one mile
  4. Left turn
  5. North one mile

The bear arrives at where he started. What color is the bear? Why?

You are given a rectangular cake with a rectangular piece removed. The removed piece is of any size or orientation.

How would you cut the remainder of the cake into two equal halves with one straight cut of a knife?