All about Mobile, Web, Technology, Politics, Security, E-Commerce and Living in the Philippines.

Sunday, November 22, 2009

Godie's Answers Google's Interview Questions

I love puzzles, especially puzzles in code so I couldn't resist answering the recently published "15 Google Interview Questions That Will Make You Feel Stupid" by to let me humor myself.

Q: How many golf balls can fit in a school bus? (Job: Product Manager)
A: As a product manager, none. Golf balls has no place on a school bus, they present as a health hazard to children and could cause a nightmarish PR event for Google. However if you insist, a school bus has an average displacement of 2511 cubic feet and given the official golf ball may not be smaller than 1.68 inches or 2.4827 cubic inch in volume. Therefore roughly 1,747,697 golf balls can be fit into a school bus without compression. Now if you say I'm wrong, then Google's calculator did an epic fail in cubic feet to cubic inch conversion because I just used that!

Q: How much should you charge to wash all the windows in Seattle? (Job: Product Manager).
A: I heard of this before and I think the answer was per square foot but I disagree, the cost would be economically not feasible so I would propose a per gallon of water and soap charging model.

Q: 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?
A: 2/3, given the probability of having a boy or a girl IS 0.5. Lets take 2 couples, one starts with a boy, the other a girl. Imposing the probability the next child of the other couple will be a boy and we end up with 2 boys and 1 girl.

Q: How many piano tuners are there in the entire world? (Job: Product Manager)
A: Every person can tune a piano! However between 0.13% and 2% of Americans are deaf, assuming the same value for the entire world population, 98% of the world population are capable of tuning a piano.

Q: Why are manhole covers round? (Job: Software Engineer)
A: So its easy to dip the other side (your weight should be enough), flip it upright by its side and roll. They can actually be put back easily as well without needing to align them properly on their correct sides. Here's actually a similar question, Why coins are round?

Q: Design an evacuation plan for San Francisco. (Job: Product Manager).
A: Everyone to the shore quick! However in case of 2012 movie like event, we simply don't.

Q: How many times a day does a clock’s hands overlap? (Job: Product Manager)
A: This one made me count. M = H + n for n=0,1,2... 22 times! But twice if you include the seconds hand.

Q: Explain the significance of "dead beef". (Job: Software Engineer).
A: Sorry I'm not from U.S. so I have no clue to the significance of the phrase, pareho ba to sa "Double Dead"? X_X

Q: A man pushed his car to a hotel and lost his fortune. What happened? (Job: Software Engineer).
A: It's a game of Monopoly and the guy who asked this is from the University of Massachusetts :D

Q: You need to check that your friend, Bob, has your correct phone number but you cannot ask him directly. You must write the question on a card which and give it to Eve who will take the card to Bob and return the answer to you. What must you write on the card, besides the question, to ensure Bob can encode the message so that Eve cannot read your phone number?
A: During high school my answer is the sum of the two numbers, during college while taking BSCS the answer is the XOR of the two numbers, when I started working we just sent md5 hashes. LOL

Q: 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? (Job: Engineering Manager)
A: Attention crew!, dis er gold is divided equally but if yer kill the other crew guy den you get his gold and double yer share! (everyone starts killing each other then after the last person is left standing) -- ahem, I was not finished saying de rule, now till only one crew is left and ill kill you so I get all! Arr! (Hey I'm supposed to act like a pirate right? :D)

Q: You have eight balls all of the same size 7 of them weigh the same, and one of them weighs slightly more. How can you find the ball that is heavier by using a balance and only two weighings? (Job: Product Manager)
A: Place the ball alternately for the first weighing, take note of the ball that does not even the scale. For the second weighing, use that ball and any other ball to compare.

Q: You are given 2 eggs. You have access to a 100-story building. Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100th floor. Both eggs are identical. You need to figure out the highest floor of a 100-story building an egg can be dropped without breaking. The question is how many drops you need to make. You are allowed to break 2 eggs in the process. (Job: Product Manager)
A: 50 drops, 1st sacrifice an egg, check if the eggs will break at 50th. If yes, start from 1st floor going to 49th. If no, start from 51 going up.

Q: Explain a database in three sentences to your eight-year-old nephew. (Job: Product Manager)
A: This is a genie in a box, you ask the genie to keep your stuff in the box and all will fit in, make changes to it or throw it out if you don't need it. If you need it back, you need to describe that item to genie but the genie may bring more that 1 stuff out that fits your description. The better you describe what you need back the more chances he genie will take out what you need.

Q: 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? (Job: Product Manager)
A: Its the 2nd time this is published, correct answer is lay down if you don't want to die, but if you're like me who prefer to see a messy ending (that's why we throw you in the blender on the first place), try jumping up and down for maximum effect.

So for those who likes puzzle questions like me, try to figure this one I made myself:

//Copyright by Roger Filomeno 2009, released under CC-BY license

$r = array(); //I'm lazy, just replace with proper input array

if (count($r[0]) != count($r)) die("invalid!");
$n = count($r);
for ($j=0;$j<$n;$j++)for($k=$n;$k<(2*$n);$k++)$r[$k][$j]=$i[($k-$n)][$j];
      $y = $r[$k][$j];
      $r[$k][$j] = $r[$k][$x];
      $r[$k][$x] =$y;
    $z = $r[$l][($b + 1)]/$r[$l][$l];
    for ($c = $l; $c < ($n * 2); $c++)
      $y = $r[$c][($b + 1)] - ($z * $r[$c][$l]);
      $r[$b][($b + 1)] = $y;
  if ($r[$l][$l]==0)die("not found");
for ($a = 0; $a < $n; $a++)
  $x = $r[$a][$a];
  for ($k = $a; $k < ($n*2); $k++)
    $y = $r[$k][$a]/$x;
    $r[$k][$a] = $y;
for ($j = 0; $j < $n; $j++)for ($k = 0; $k < $n; $k++) $i[$k][$j] = $r[($k + $n)][$j];


Related Links