Accidentally in Code

Google Interview Questions

Posted on: November 9, 2009

Like pretty much every software engineer, Google is probably my dream job. One of my good friends works at Google, and he loves it. The Googleplex (in London) was amazing when he took me around it. Let’s admit it – there’s something about the wacky creativity, the changing of the Google logo for Sesame St. etc combined with the cutting edge technology (Wave? Google Voice?) that catches our attention.

So I was interested to see this list of interview questions in the Guardian. My first thought – arrgh I have no idea how to answer these. But with the help of Google itself, maybe I can have a go. At the end of it, a lot of them that seemed intimidating just rely on estimating and justifying your reasoning. That’s not so hard, but I still don’t get the one about the pirates…

Why are manhole covers round?

I had some idea about this one – round covers can’t fall through the hole itself, and don’t need to be rotated to be put back (important when they’re heavy, which obviously they need to be because cars drive on them). Wikipedia has a whole host of other answers though! See here.

You are shrunk to the height of a nickel and your mass is proportionally reduced so as to maintain your original density. You are then thrown into an empty glass blender. The blades will start moving in 60 seconds. What do you do?

This question is nuts. The real kicker is (I think) that it’s hard to conceptualize how small you are. From money.cnn, these responses

  1. Use the measurement marks to climb out
  2. Try to unscrew the glass
  3. Risk riding out the air current

How much should you charge to wash all the windows in Seattle?

number of hours spent cleaning = (estimate of number of buildings x estimate of number of windows per building) / estimate of number of windows per hour

what you should charge = number of hours spent cleaning x hourly rate

Explain a database in three sentences to your eight-year-old nephew.

A database is like a super-organized folder of “records” and each “record” is standardized in terms of what information is where, so that it’s really easy to find what we’re looking for. So for people, we might organize records by name, and in each record we’d want information like their first name, middle name, last name, birthday, etc. We can even link to other records, for example by having a place in the record for a list of their friends.

In a country in which people only want boys, every family continues to have children until they have a boy. If they have a girl, they have another child. If they have a boy, they stop. What is the proportion of boys to girls in the country?

Assume a 50/50 chance of having a boy or a girl.

50% of families will have a boy the first time, and stop right away.

50% will have a girl, of this 50%, half (so 25% of the total) will have a boy the second time, and stop. And so on.

So if there are N families, there will be N boys.

For girls, there will be the sum of (N/2) + (N/4) + (N/8) + … – the theoretical maximum of this is N. So it will be a little under 1:1.

Counter intuitive, huh? More detailed answer here.

If you look at a clock and the time is 3.15, what is the angle between the hour and the minute hands? (The answer is not zero!)

360 = number of degrees in the whole clock

12 = the number of hours

4 = the number of 15 minutes in each hour

360/(12*4) = 7.5 degrees

How many piano tuners are there in the entire world?

This is an approximation question, requiring various assumptions. First, how many piano tuners are there in the population in the US? Say A per B (this will be thousands) of people. Then consider the population of the US (P) to come up with a number in the US. Then, given that people in less developed countries probably don’t have as many pianos, what proportion of the world’s piano tuners likely exist in the US? Say 1/D.

Estimate: A x (P/B) x D

Four people need to cross a rickety rope bridge to get back to their camp at night. Unfortunately, they only have one flashlight and it only has enough light left for 17 minutes. The bridge is too dangerous to cross without a flashlight, and it’s only strong enough to support two people at any given time. Each of the campers walks at a different speed. One can cross the bridge in one minute, another in two, the third in five, and the slow poke takes 10 to cross. How do the campers make it across in 17 minutes?

Key points: they have to cross the bridge in 2’s and someone has to keep going back with the flashlight. So first idea is to have them go across and use the fastest person to go back

Time = 0: 1 min and 10min go across together

Time = 10: 1 min goes back

Time = 11: 1 min and 5 min go over

Time = 16: 1 min goes back

Time = 17: flash light is out, 1 min and 2 min are stranded.

Hmm… must be smarter. Perhaps if we just say that the flashlight must be on the bridge whilst they are moving?

Time = 0: 1 min and 5 min set off (5 min has flash light)

Time = 1: 1 min makes it across, 2 min sets off

Time = 3: 2 min arrives

(note to stay close to the light, this can happen any time up to time = 5 – the point is that 1 min and 2 min cross whilst 5 min is crossing)

Time = 5: 5 min arrives, 1 min goes back with flashlight

Time = 6: 1 min arrives back, leaves with 10 min

Time = 16: 1 min and 10 min arrive.

Feel like this is cheating, so I looked up here. If you have the two slowest people cross together, then the 2nd slowest is never a limiting factor. So I can refine my first idea:

Time = 0: 1 min and 2 min go over

Time = 2: Arrive, 2 min goes back

Time = 4: 5 min and 10 min leave together

Time = 14: 5 min and 10 min arrive, 1 min goes back

Time = 15: 1 min arrives, departs with 2 min

Time = 17: Everyone is across, flashlight runs out.

I’ve heard this question before, I feel stupid for not getting it sooner now!! I guess it’s supposed to make you think about whether the fastest solution (1 min) is always the best to use – in this case, not, because it means sending over the two slow guys separately.

How many golf balls can fit in a school bus?

This can be oversimplifies by treating the balls as cubes and estimating how many fit width-wise (W), height-wise (H) and depth-wise (D) and saying total = W x H x D.

This is less than will actually fit though, because of them actually being spherical so it would be possible to arrange the balls to take better advantage of that space.

You’re the captain of a pirate ship, and your crew gets to vote on how the gold is divided up. If fewer than half of the pirates agree with you, you die. How do you recommend apportioning the gold in such a way that you get a good share of the booty, but still survive?

Egalitarian views get in the way here, and I just want to split it up equally…

Then I think about findings in Stumbling on Happiness (Amazon) and think that as long as the other pirates believe I deserve it (I’ve “won” it) they’ll be OK with me having it.

This thinking is really clouded by the thought that it would be horrible to be killed by a bunch of pirates, though.

The Times has an answer, but I’m not sure it’s optimal…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Tweet Tweet

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

%d bloggers like this: