Popular Posts

Saturday, May 5, 2012

The odd interview questions and answers

1. What's the next number in this sequence: 10, 9, 60, 90, 70, 66 … ?
Asked at Google

2. You're in a car with a helium balloon on a string that is tied to the floor. The windows are closed. When you step on the gas pedal, what happens to the balloon—does it move forward, move backward, or stay put? 
Asked at Microsoft

3. Using only a four-minute hourglass and a seven-minute hourglass, measure exactly nine minutes—without the process taking longer than nine minutes. 
Asked at Google

4. A book has N pages, numbered the usual way, from 1 to N. The total number of digits in the page numbers is 1,095. How many pages does the book have?
Asked at Google

5. A man pushed his car to a hotel and lost his fortune. What happened? Asked at Google

6.How many people are using Facebook in San Francisco at 2:30 p.m. on a Friday? — Asked at Google, Vendor Relations Manager candidate

7.How can I determine the highest floor of a 100 story building that an egg can be dropped from without breaking if I have two eggs?

8.How would you cure world hunger?— Asked at Amazon.com, Software Developer candidate

9.You’re in a row boat, which is in a large tank filled with water. You have an anchor on board, which you throw overboard (the chain is long enough so the anchor rests completely on the bottom of the tank). Does the water level in the tank rise or fall?— Asked at Tesla Motors, Mechanical Engineer candidate

10.You have a bouquet of flowers. All but two are roses, all but two are daisies, and all but two are tulips. How many flowers do you have? — Asked at Epic Systems, Corporation Project Manager/Implementation Consultant candidate

11.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? Asked at Facebook.

12.Why are manhole covers are round? -- Asked at Google

13.There are three boxes, one contains only apples, one contains only oranges, and one contains both apples and oranges. The boxes have been incorrectly labeled such that no label identifies the actual contents of the box it labels. Opening just one box, and without looking in the box, you take out one piece of fruit. By looking at the fruit, how can you immediately label all of the boxes correctly? ----Asked at Google

14.How would you explain a database in three sentences to your 8-year-old nephew?---Asked at Google

ANSWERS

1. What's the next number in this sequence: 10, 9, 60, 90, 70, 66 … ?

A. Spell the numbers out: 
Ten
Nine
Sixty
Ninety
Seventy
Sixty-six

They are in ascending order, based on the number of letters in the spelled-out numbers. A correct response will have nine letters: 96, for instance. A cleverer answer is "one googol." That's the huge number that can be written as a "1" with a hundred zeros after it. Google, the company's name, was originally a misspelling of "googol."

2. You're in a car with a helium balloon on a string that is tied to the floor. The windows are closed. When you step on the gas pedal, what happens to the balloon—does it move forward, move backward, or stay put?

A. The near-universal intuition is that the balloon leans backward as you accelerate. Well, the intuition is wrong. Your job is to deduce how the balloon does move and to explain it to the interviewer.
One good response is to draw an analogy to a spirit level. For the not so handy, a spirit level is the little gizmo carpenters use to make sure a surface is horizontal. It contains a narrow glass tube of colored liquid with a bubble in it. Whenever the spirit level rests on a perfectly horizontal surface, the bubble hovers in the middle of the tube. When the surface isn't so level, the bubble migrates to the higher end of the tube. The takeaway here is that the bubble is simply a "hole" in the liquid. When the surface isn't level, gravity pulls the liquid toward the lower end. This pushes the bubble wherever the liquid isn't— toward the opposite end.


Untie the helium balloon and let it hit the moonroof. It becomes a spirit level. The balloon is a "bubble" of lower-density helium in higher-density air, all sealed in a container (the car).

Gravity pulls the heavy air downward, forcing the light balloon against the moonroof.

When the car accelerates, the air is pushed backward, just as your body is. This sends a lighter-than-air balloon forward. When the car brakes suddenly, the air piles up in front of the windshield. This sends the balloon backward. Centrifugal force pushes the air away from the turn and sends the balloon toward the center of the turn. Of course, the same applies when the balloon is tied to something; it's just less free to move. The short answer to this question is that the balloon nods in the direction of any acceleration.

3. Using only a four-minute hourglass and a seven-minute hourglass, measure exactly nine minutes—without the process taking longer than nine minutes.

A. Start both hourglasses at 0 minutes. Flip over the four-minute glass when it runs out (at 4:00); ditto for the seven-minute glass (at 7:00). When the four-minute glass runs out the second time (at 8:00), the seven-minute glass will then have one minute of sand in its lower bulb. Flip the seven-minute glass over again and let the minute of sand run back. When the last grain falls, that will be nine minutes.

4. A book has N pages, numbered the usual way, from 1 to N. The total number of digits in the page numbers is 1,095. How many pages does the book have?

A. Every page number has a digit in the units column. With N pages, that's N digits right there. All but the first 9 pages have a digit in the tens column. That's N - 9 more digits.

All but the first 99 pages have a digit in the hundreds column (accounting for N - 99 more digits).

I could go on, but not many books have more than 999 pages. A book with 1,095 digits in its page numbers won't, anyway.

This means that 1,095 must equal:

N + (N - 9) + (N - 99).

This can be simplified to:

1,095 = 3N - 108.

That means that 3N = 1,203, or N = 401. That's the answer, 401 pages.

5. A man pushed his car to a hotel and lost his fortune. What happened?

A. He was playing Monopoly.

6.How many people are using Facebook in San Francisco at 2:30 p.m. on a Friday?”

A.40% more than should be, considering 2:30 is when most people are working.

7.How can I determine the highest floor of a 100 story building that an egg can be dropped from without breaking if I have two eggs?

A.Interview candidates never get this correct. It's actually pretty difficult, as most people start down the wrong track. First, everyone assumes binary search- which is wrong. Then everyone tries to minimize the equation

(100/n - 1) + (n - 1)

The first term indicates the maximum number of drops for the first egg, while the second term indicates the maximum number of drops for the second egg. The obvious answer for n is 10, which gives you a maximum of 18. This is wrong.

What we should optimize for instead is always having the same maximum number of drops left regardless of the outcome. Every time the egg doesn't break, we should have n-1 drops remaining; and if the egg does break, we should have n-1 drops remaining. This forces us to always increment our floor by one fewer whenever the first egg does not break. If we were to start at floor 10, we would then have to move to floor 19, then 28, and so on. Thus the floors on which we should drop the first egg (assuming no breaks) are:

n
n + n - 1
n + n - 1 + n - 2
n + n - 1 + n - 2 + n - 3
...

Which, after n iterations, needs to be above 100. To simplify, this basically means we should find the minimum value for n such that that SUM(1..n) >= 100.

n(n+1)/2 > 100 implies n > 13. Thus, n = 14, both our starting floor and the number of iterations required to figure out the strength of the eggs.

8.How would you cure world hunger?

A.(An oft-ignored factor underlying the dramatic growth in economic productivity in East Asia and South Asia in the latter half of the 20th century is the dramatic improvement in crop yields in these regions, an improvement that has yet to occur in most of Sub-Saharan Africa.)
Higher agricultural productivity makes it much easier for a country to be self-sufficient. More food = less hunger, export opportunities, and a larger proportion of the labor force that can get an education and move up to higher-paying jobs.

Achieving this is far from simple, but in India (as well as Pakistan and Mexico), the improvement is attributed largely to the work of people like Nobel Laureate Norman Borlaug, who developed genetically modified grain varieties that were disease-resistant and offered higher yields. This change is often referred to as "The Green Revolution." However, a given improvement often works only in a given climate, and we have largely yet to achieve this same revolution for most of sub-Saharan Africa.

Thus, believe that history tells us that part of the effort to end world hunger should be research for seed varieties and farming techniques that lead to higher crop yields in the world's poorest countries. 

9.You’re in a row boat, which is in a large tank filled with water. You have an anchor on board, which you throw overboard (the chain is long enough so the anchor rests completely on the bottom of the tank). Does the water level in the tank rise or fall?.

A:The water level drops, because while in the boat, the anchor displaces water of equal mass, but when outside the boat, it only displaces water of equal volume, and since the anchor is denser than water, then water of equal mass to the anchor has more volume

10.You have a bouquet of flowers. All but two are roses, all but two are daisies, and all but two are tulips. How many flowers do you have?
A.3 flowers. 1 of each. 

11.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?

A.Break the balls into the following groups: (1,2,3),(4,5,6),(7,8)

Step 1. Weigh (1,2,3) against (4,5,6)
Two possible outcomes: 
The two groups are equally heavy. (Case A)
One of these groups is heavier than the other. (Case B)

Case A --> Weigh 7 against 8. Now you have identified the heavier ball in 2 weighing.
Case B --> Take the heavier group (assume it to be (1,2,3)), take any two balls and weigh them against each other. Either one of these is heavier else the third ball is.

12.Why are manholes cover round?

A.Round covers are used when the hole they are covering up is also round. It's simplest to cover a round hole with a round cover.
We have to look at what is under the cover to answer that question. The hole below the cover is round because a cylinder is the strongest shape against the compression of the earth around it. Also, the term "manhole" implies a passage big enough for a man, and a human being climbing down a ladder is roughly circular in cross-section. So a cylindrical pipe is the natural shape for manholes. The covers are simply the shape needed to cover up a cylinder
http://hebig.org/blog/003029.php

13.There are three boxes, one contains only apples, one contains only oranges, and one contains both apples and oranges. The boxes have been incorrectly labeled such that no label identifies the actual contents of the box it labels. Opening just one box, and without looking in the box, you take out one piece of fruit. By looking at the fruit, how can you immediately label all of the boxes correctly?

A.Open the box that is labeled "Apples and Oranges".

You know that since none of the labels are correct, the box must either contain only apples, or only oranges.

Suppose, w.l.o.g., that you remove an apple from that box. Therefore, that box is the "Apples Only" box.

One of the two remaining boxes must be the "Oranges Only" box. However, one of them is labeled "Apples Only", and the other is labeled "Oranges Only". Therefore, the one labeled "Apples Only" is the box that contains only oranges, and the box labeled "Oranges Only" is the box that has both kinds of fruit.

14.How would you explain a database in three sentences to your 8-year-old nephew?

A.You know how you have to put your toys away when you're done playing, so you can find them easily the next time you want to play with them?

A database is like a shelf to put your toys away, except the toys are data instead.

Now, the database can always find the right data easily - whether it's "all the dinosaur toys" or "all the yellow toys," the computer can get everything out to play with very quickly, because it's in a database.

http://techgurustalk.blogspot.com/2011/12/odd-interview-questions-and-answers.html

No comments:

Post a Comment