Here is a list of 10 puzzles which have been asked on a Google Interview. They are not in any specific order.

Reverse a Linked-list. Write code in C.

Write a method to generate a random number between 1 and 7, given a method that generates a random number between 1 and 5. Answer

You are given an array with integers (both positive and negative) in any random order. Find the sub-array with the largest sum.

You have two identical eggs. Standing in front of a 100 floor
building, you wonder what is the maximum number of floors from which the
egg can be dropped without breaking it. What is the minimum number of
tries needed to find out the solution?

Four people need to cross a rickety bridge at night. Unfortunately,
they have only one torch and the bridge is too dangerous to cross
without one. The bridge is only strong enough to support two people at a
time. Not all people take the same time to cross the bridge. Times for
each person: 1 min, 2 mins, 7 mins and 10 mins. What is the shortest
time needed for all four of them to cross the bridge?

In a country where everyone wants a boy, each family continues having
babies till they have a boy. After some time, what is the proportion of
boys to girls in the country? (Assuming probability of having a boy or a
girl is the same)

The probability of a car passing a certain intersection in a 20
minute windows is 0.9. What is the probability of a car passing the
intersection in a 5 minute window? (Assuming a constant probability
throughout)

You have a stream of bytes from which you can read one byte at a
time. You only have enough space to store one byte. After processing
those bytes, you have to return a random byte. Note: The probability of
picking any one of those bytes should be equal.

How would you cut a rectangular cake into two equal pieces when a
rectangular piece has already been cut out of it? The cut piece can be
of any size and orientation. You are only allowed to make one straight
cut.

Two old friends, Jack and Bill, meet after a long time.

Jack: Hey, how are you man?

Bill: Not bad, got married and I have three kids now.

Jack: That’s awesome. How old are they?

Bill: The product of their ages is 72 and the sum of their ages is the same as your birth date.

Jack: Cool… But I still don’t know.

Bill: My eldest kid just started taking piano lessons.

Jack: Oh now I get it.

Bill: Not bad, got married and I have three kids now.

Jack: That’s awesome. How old are they?

Bill: The product of their ages is 72 and the sum of their ages is the same as your birth date.

Jack: Cool… But I still don’t know.

Bill: My eldest kid just started taking piano lessons.

Jack: Oh now I get it.

How old are Bill’s kids?

Here is a list of 10 famous puzzles which have been asked on a Microsoft Interview. They are not in any specific order.

How many times a day do the minute and hour hands of a clock overlap? Answer

A certain town comprises of 100 married couples. Everyone in the town
lives by the following rule: If a husband cheats on his wife, the
husband is executed as soon as his wife finds out about him. All the
women in the town only gossip about the husbands of other women. No
woman ever tells another woman if her husband is cheating on her. So
every woman in the town knows about all the cheating husbands in the
town except her own. It can also be assumed that a husband remains
silent about his infidelity. One day, the mayor of the town announces to
the whole town that there is at least 1 cheating husband in the town.
What do you think happens? Answer

100 prisoners are stuck in the prison in solitary cells. The warden
of the prison got bored one day and offered them a challenge. He will
put one prisoner per day, selected at random (a prisoner can be selected
more than once), into a special room with a light bulb and a switch
which controls the bulb. No other prisoners can see or control the light
bulb. The prisoner in the special room can either turn on the bulb,
turn off the bulb or do nothing. On any day, the prisoners can stop this
process and say “Every prisoner has been in the special room at least
once”. If that happens to be true, all the prisoners will be set free.
If it is false, then all the prisoners will be executed. The prisoners
are given some time to discuss and figure out a solution. How do they
ensure they all go free? Answer

Three ants are sitting at the three corners of an equilateral
triangle. Each ant starts randomly picks a direction and starts to move
along the edge of the triangle. What is the probability that none of the
ants collide? Answer

You’ve got someone working for you for seven days and a gold bar to
pay them. You must pay the worker for their work 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? (Assuming equal amount of work is done during each
day thus requiring equal amount of pay for each day) Answer

A train leaves City X for City Y at 15 mph. At the very same time, a
train leaves City Y for City X at 20 mph on the same track. At the same
moment, a bird leaves the City X train station and flies towards the
City Y train station at 25 mph. When the bird reaches the train from
City Y, it immediately reverses direction. It then continues to fly at
the same speed towards the train from City X, when it reverses its
direction again, and so forth. The bird continues to do this until the
trains collide. How far would the bird have traveled in the meantime? Answer

You have 10 boxes of balls (each ball weighing exactly10 gm) with one
box with defective balls (each one of the defective balls weigh 9 gm).
You are given an electronic weighing machine and only one chance at it.
How will find out which box has the defective balls?

How many points are there on the globe where, by walking one mile
south, then one mile east and then one mile north, you would reach the
place where you started?

If you had an infinite supply of water and a 5 quart and 3 quart
pails, how would you measure exactly 4 quarts? and What is the least
number of steps you need? Answer

Four people need to cross a rickety bridge at night. Unfortunately,
they have only one torch and the bridge is too dangerous to cross
without one. The bridge is only strong enough to support two people at a
time. Not all people take the same time to cross the bridge. Times for
each person: 1 min, 2 mins, 7 mins and 10 mins. What is the shortest
time needed for all four of them to cross the bridge?

How many can you answer in the first attempt? Post in comments.

d ques on quarts waater iz easy!

ReplyDeletetake 2- 5lit cans and two 3 lit cans fill the 5 lit can's and now transfer 5 lit to 3-lit upto brim do it to the other similarly;

now remaining capacity is 2 lit in each so we can measure 4 lit of water!!

ya gud one & i think it's d shortest!!!

ReplyDelete