10 Google Interview Puzzles

Coding Challenge Coding Live

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)Answer

so if you list all the possible cases youll see that there are

However, the piano question isnt quite right. It is possible that the kids are 2, 6, and 6, but the 6-year-olds were born, say, 11 months apart, and the older 6-year-old has just started piano.

50, 25, 13, 7, 4, 2, 1. so 7 tries

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?Answer

Even an Ostrich egg, one of the hardest and largest currently on the planet, would crack at a fall of more than 3-4 ft. So the answer is Floor 1. Part of business is deciding what questions matter and which dont. These types of questions test whether employees can have fun together, not solve real world problems together. I suggest both Google and Microsoft look at the management consulting firm questions which are equally complex but based in reality. For example, a copper mining company does $300M in one year, and the next year is doen $50M. What is the strategy for recovering that lost revenue? The other example is the two buckets my answer is just 5 steps and call legal counsel. 1. Fill the 5gal buget; 2. Pour 3 gals into the second bucket and you have 2 gals remaining in the first bucket, you are half way done having measured two gals; 3. Throw out the water from both buckets; 4. Fill the 5 gal bucket again; 5 empty into the 3 gal bucket and again you are left with 2 gals in the first bucket. You have now measured 4 gals. No one said anything about retaining the water, only that you measure 4 gals call legal and they will concur. THAT is a practical, more efficient solution that any person engaged in business is in fact higly likely to deal with, the parsing of legal language to come to the most efficient solution to a problem.

you drow a line that goes on centers of both rectangles.

Why is this case ignored? Isnt more data required to break the tie and get a unique solution?

Can we solve first question in Java as well ?

then he mentioned eldest kid so answer is 3 3 8, because there is no eldest kid in 2 6 6.

Josh you only have 2 eggs. If you break them both, then you have nothing else to drop.

Because Jacks Birth date is 14th not 15th!!

traffic, you can earn additional cash every month because youve got high quality content.

XHTML:These are some of the tags you can use:a href= b blockquote code em i strike strong

If youre looking for some serious preparation for your interviews, Id recommendthis book written by a lead Google interviewer. It has 189 programming questions and solutions:

Jack: Cool But I still dont know.

@ Josh- dude u r wrong about the egg problem. u r saying that Start at 50, if it breaks, go to 25, otherwise 75. If at 25 and it breaks, go to 13. How will u go to 13 if ur second egg already broke on the 25th floor. U have only 2 eggs. The optimum value of no. of tries is 14 , u cant reduce it any more..:)

The Boys and Girls question reminds me of people who think they have a roulette system. No matter when you stop or start, you cant get around the fact that each individual roulette bet is a losing one, and these couples cant get around the fact that each individual birth is 50/50.

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

Nice post , all are great tricky questions and can increase our mind and make it sharp . and help in our interviews.

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

i knew 4 of them already (cheating, pirates, bridge and children age) the others the only one i didnt got at the first try was the eggs problem optimal solution.

If you want to know how to make extra bucks, search for: Boorfes tips best adsense

Jack: Thats awesome. How old are they?

3,3,8, which implies the eldest start piano at 8 years old and he has a twin kids (3,3).

Neha, if they were 9,4,2 the sum would be unique (15) and Jack would have found out. He got confused because there was a tie.

In this case, in addition to the two cases which add up to 14 (as pointed out in the solution), there is another case wherein the ages add up to 13:

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)Answer

I have noticed you dont monetize your website, dont waste your

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.Answer

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?Answer

Start at 50, if it breaks, go to 25, otherwise 75. If at 25 and it breaks, go to 13, otherwise 38, and so on. Maximum should be:

Regarding how many children question,

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

OMG I was asked the question about piece of cake when I was in 6th grade ?

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

The answer to the cheating husbands is wrong. It states that The 1 remaining woman, who is being cheated on, would have assumed there are no cheaters However, they are all being cheated on, and as the mayor did not specify who was the cheater the status quo remains unchanged. All women know about everyones husband except their own, i.e. they are all aware of 99 cheaters- saying that there is definitely a cheater, would in no way cause one woman to assume that there are no cheaters, as the answer states.

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.Answer

Whether you get the job you want really depends on your answers during the interview, even so during this economic crisis!

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

Children usually start learning piano around 6. I think this is better than

These puzzles are quite interesting!!!!!!!!!

Bill: My eldest kid just started taking piano lessons.

Reverse a Linked-list. Write code in C.Answer

UsingGravatarsin the comments – get your own and be recognized!

Challenge Equal Probability between 1 and 7

he couldnt make decision, therefore there must be at least two combinations which add up to his birth date

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

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

For the question How old are my children, arent a lot of possibilities neglected? eg Why arent there any children with age 1?

Feel free to add to this list or leave a comment. Please tweet, Digg or Stumble.

Chester 3,4,6 is the only triple that multiplies to 72 and adds to 13, so Jack would have known the ages before hearing about the piano lessons. He didnt, so that doesnt work.

Hi Amol, Thanks for pointing that out. I have added all the options. 12, 6, 1. The sum is 19 not 13 so there will not be a conflict in that case.

How old are Bills kids?Answer

For the eggs problem, how is it not a better solution to just divide the interval?

Leave a Reply