Microsoft Interview Questions and Answers
Yesterday on twitter someone posted a link to a list of Microsoft Interview Questions. I really enjoy challenging interview questions, so I’m going to attempt to answer some of them and see how I do, similar to what I did with the Google Interview Questions a while ago.
Again, I didn’t use Google to search for any answers, so keep that in mind if my answers seem idiotic.
The Questions
If a bear walks one mile south, turns left and walks one mile to the east and then turns left again and walks one mile north and arrives at its original position, what is the color of the bear?
White. The only way you could possibly walk south 1 mile, east 1 mile, north 1 mile and end up in the same spot is if you’re standing on one of the poles of the earth. Since the only bears which hang around the artic regions (according to my knowledge) are polar bears (which are white), the bear has to be white.
Given a rectangular cake with a rectangular piece removed 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?
You would need to cut a straight line from the center of the missing piece to the center of the rest of the cake. It’s tricky to do the math behind this, but I came to this conclusion by running through a bunch of scenarios and this seems to be the only answer that makes sense.
There are 3 baskets. one of them have apples, one has oranges only and the other has mixture of apples and oranges. The labels on their baskets always lie. (i.e. if the label says oranges, you are sure that it doesn’t have oranges only,it could be a mixture) The task is to pick one basket and pick only one fruit from it and then correctly label all the three baskets.
Easy. Pick a fruit from the basket that says ‘mixture’. If it’s an apple, the basket that says ‘apples’ has oranges only and the one that says ‘oranges’ is a mixture. If it’s an orange, the basket that says ‘oranges’ has apples only and the one that says ‘apples’ is a mixture. The key is that the basket that says ‘mixture’ can only contain one type of fruit, so there are really only 2 possibilities. It’s maybe the easiest to explain with a table.
Actual | Apples | Oranges | Mixture |
Labels | Oranges | Mixture | Apples |
Labels | Mixture | Apples | Oranges |
You have 8 balls. One of them is defective and weighs less than others. You have a balance to measure balls against each other. In 2 weighings how do you find the defective one?
Take 2 groups of 3 balls and measure them. If the 2 groups are equal, take the 2 balls you haven’t measured and measure them to find the lightest one. If the 2 groups aren’t equal, take 2 balls from the group which weighs less and measure them. If the 2 balls are equal the ball you didn’t measure is the defective one, otherwise the balance will show you the defective one.
Why are manhole covers round?
This one came up in the list of Google interview questions as well. Seriously, nobody still asks this in interviews. Well, maybe they want to see if you can think past the obvious answer. The obvious answer, of course, is because they can’t fall through the hole. However, that’s not the whole answer – for example, there is a class of shapes called Reuleaux polygons which also can’t fall through their holes. (Seriously, Google it) Round manhole covers are also useful because they can be rolled, making them easier to move, and they don’t need to be aligned to the hole – they will fit any which way. However, at the end of the day I think manhole covers are round because they’re probably the cheapest shape to manufacture. I could be wrong.
How many cars are there in the USA?
This is obviously the type of question where you have to use estimates and guesses and the correctness of your answer isn’t really important, it’s more about how you got to the answer. There are about 300 million people in the USA. I’m not sure what the legal driving age is in America, but I think around 25% of the population would be below the age of 18, making it unlikely for about 75 million people to own a car. The USA has good public transport, so I would guess maybe about 60% of the population over 18 would own a car (I think people who own more than one car are statistically insignificant). So I would say there are about 135 million cars in the USA.
You’ve got someone working for you for seven days and a gold bar to pay them. The gold bar is segmented into seven connected pieces. You must give them a piece of gold at the end of every day. If you are only allowed to make two breaks in the gold bar, how do you pay your worker?
Another easy one. Break off a piece with a single segment and another piece with 2 segments. You will be left with a piece that has 4 segments. On the first day, give the single segment to the worker. On the second day, take back the single segment and give the piece with 2 segments. On the third day, give the piece with 1 segment to add to the piece with 2 segments the worker already has. On the fourth day, take back the first 2 pieces and give the piece with 4 segments. On the fifth day give the piece with 1 segment. On the sixth day take back the piece with one segment and give the one with 2 segments. On the seventh day give the piece with one segment. Don’t you wish you were also paid in gold?
That’s all I can handle for now, I might do some more in a future post. Happy coding.