Velocity Reviews > Hardest Google Interview Question

divya bisht
Guest
Posts: n/a

 10-23-2011

http://hardest-puzzle.blogspot.com/2...-question.html

Malcolm McLean
Guest
Posts: n/a

 10-23-2011
On Oct 23, 8:39*am, divya bisht <(E-Mail Removed)> wrote:
>
> http://hardest-puzzle.blogspot.com/2...rview-question....
>

Drop from first floor. If it doesn't break, pick up the egg, and try
the second floor, and so on. When it breaks, you know the critical
floor.
--
Visit my website, lots of programming goodies
http://www.malcolmmclean.site11.com/www

Willem
Guest
Posts: n/a

 10-23-2011
Malcolm McLean wrote:
) On Oct 23, 8:39?am, divya bisht <(E-Mail Removed)> wrote:
)>
)> http://hardest-puzzle.blogspot.com/2...rview-question....
)>
) Drop from first floor. If it doesn't break, pick up the egg, and try
) the second floor, and so on. When it breaks, you know the critical
) floor.

If this is the puzzle I think it is, you're supposed to have two eggs, and
the question is to determine the minimal number of drops which guarantees

SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT

Malcolm McLean
Guest
Posts: n/a

 10-23-2011
On Oct 23, 10:53*am, Willem <(E-Mail Removed)> wrote:
> Malcolm McLean wrote:
>
> ) On Oct 23, 8:39?am, divya bisht <(E-Mail Removed)> wrote:
> )> Hardest Google Interview Question
> )>
> )>http://hardest-puzzle.blogspot.com/2...rview-question.....
> )>
> ) Drop from first floor. If it doesn't break, pick up the egg, and try
> ) the second floor, and so on. When it breaks, you know the critical
> ) floor.
>
> If this is the puzzle I think it is, you're supposed to have two eggs, and
> the question is to determine the minimal number of drops which guarantees
>

The obvious method is a binary search. However you are only allowed to
break a maximum of two eggs, and you have 100 floors to search, so it
won't work.

Willem
Guest
Posts: n/a

 10-23-2011
Malcolm McLean wrote:
) On Oct 23, 10:53?am, Willem <(E-Mail Removed)> wrote:
)> Malcolm McLean wrote:
)>
)> ) On Oct 23, 8:39?am, divya bisht <(E-Mail Removed)> wrote:
)> )> Hardest Google Interview Question
)> )>
)> )>http://hardest-puzzle.blogspot.com/2...rview-question....
)> )>
)> ) Drop from first floor. If it doesn't break, pick up the egg, and try
)> ) the second floor, and so on. When it breaks, you know the critical
)> ) floor.
)>
)> If this is the puzzle I think it is, you're supposed to have two eggs, and
)> the question is to determine the minimal number of drops which guarantees
)>
) The obvious method is a binary search. However you are only allowed to
) break a maximum of two eggs, and you have 100 floors to search, so it
) won't work.

The obvious method with 2 eggs is to use the first egg in increments of 10
floors until it breaks, and then use the second on the 10-floor interval
below the floor where the first one broke. 19 drops worst case, IICC.

But you can do better than that.

SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT

Richard Damon
Guest
Posts: n/a

 10-23-2011
On 10/23/11 5:40 AM, Willem wrote:
> Malcolm McLean wrote:
> ) On Oct 23, 10:53?am, Willem<(E-Mail Removed)> wrote:
> )> Malcolm McLean wrote:
> )>
> )> ) On Oct 23, 8:39?am, divya bisht<(E-Mail Removed)> wrote:
> )> )> Hardest Google Interview Question
> )> )>
> )> )>http://hardest-puzzle.blogspot.com/2...rview-question....
> )> )>
> )> ) Drop from first floor. If it doesn't break, pick up the egg, and try
> )> ) the second floor, and so on. When it breaks, you know the critical
> )> ) floor.
> )>
> )> If this is the puzzle I think it is, you're supposed to have two eggs, and
> )> the question is to determine the minimal number of drops which guarantees
> )>
> ) The obvious method is a binary search. However you are only allowed to
> ) break a maximum of two eggs, and you have 100 floors to search, so it
> ) won't work.
>
> The obvious method with 2 eggs is to use the first egg in increments of 10
> floors until it breaks, and then use the second on the 10-floor interval
> below the floor where the first one broke. 19 drops worst case, IICC.
>
> But you can do better than that.
>
>
> SaSW, Willem

These sort of questions aren't really all that great for interviews, as
they are the sort of thing that if you have seen this particular one
before, it becomes trivial, if not, it requires a bit of thought, and
the pause to do that becomes unnatural in the interview. They much more
test how the interviewee handles being flustered under pressure than
problem solving. Unless you are interviewing for something like tech
support where your expect them to be hit with weird questions as part of
their line of work, they aren't that good of a measure.

As to this particular one, the key is to turn the problem around a bit.
If we ask how tall of a building can we measure with n drops and m
broken eggs.

If we are only allowed to break 1 egg, then the only way to solve it is
to start at the lowest floor and keep moving up, until we break, and
thus we can measure an n story building.

If we are allowed to break 2 eggs, then we can say that for the first
drop, assuming it breaks, we have n-1 drops left, so by above we could
measure n-1 floor below, so if we drop from the n story, and it break,
we can use our second allowed break to figure out which floor it would
happen at. If it doesn't, then we have n-1 drop left, and by the same
logic we can go up n-1 more stories, to floor n+(n-1) for this drop.
Continuing on, we eventually get to the floor n+(n-1)(n-2)...+1 which is
known to be floor n*(n+1)/2 (the formula for triangle numbers)

we can then extend this to breaking 3 eggs, and we will end up
sequencing on the pyramid numbers (the sum of triangle numbers), but
this is beyond what we need to do for this problem.

Since we have a 100 story building, this requires an n of at least 14.
So we drop the first egg from floor 14, if it doesn't break the next
from floor 27, then 35, 46, ... and when we break an egg, you start from
the floor above which you last didn't break and move up.

Of course, the real flaw with the problem is it assumes something that
is unlikely, that both eggs would have broken from exactly the same
height, and that drops from a lower height don't affect the height that
the egg can stand before it does break. If you don't make these
unwarranted assumptions I don't think it is possible to find a solution.

James Kuyper
Guest
Posts: n/a

 10-24-2011
On 10/24/2011 01:23 PM, christian.bau wrote:
....
> distributions (starting by dropping an egg from the first floor is
> very likely to give the correct answer very, very quickly),

For an unprotected egg landing on a paved sidewalk, that's probably true.
50's or 60's who, for fun, started testing dropping eggs in containers
(I'm not sure which kind - certainly not the modern styrofoam ones) from
high altitudes onto grassy fields. The were flying for some other
reason, they just dropped the eggs for fun (I think - maybe they were
testing for the Berlin airlift?). They found that, on average, only a
few eggs out of each dozen were broken.

Edward A. Falk
Guest
Posts: n/a

 10-24-2011
In article <(E-Mail Removed)>,
christian.bau <(E-Mail Removed)> wrote:
>On Oct 23, 7:39*am, divya bisht <(E-Mail Removed)> wrote:
>>
>> http://hardest-puzzle.blogspot.com/2...rview-question....

I would be surprised if they're still asking that one; Google tends
to ban questions that are too widely known.

These questions are asked to test to see if you can work out problems
and to get a look into your thought process. In my experience, the
interviewer will generally coax you along rather than force you to
flounder if you don't get it right away. Of course, if you *do*
get it right away, that's even better.

>That's their hardest question? Seriously? Apart from the problem that
>the "question" in the end is a bit unclear. The number of drops needed
>obviously depends on something you don't know, which is the lowest
>height that will break the egg.

Question specifies that it could break anywhere from the first
to the last floor.

>A clearer question would be "which
>strategy gives the lowest expected number of drops", given some
>distribution of probabilities, or "which strategy produces the
>smallest maximum number of drops".

We generally asked the interviewee to optimize the worst-case
scenario for number of drops. If they got it easily enough,
we'd ask what the expected number of drops was. You'd be
depressed to know how few interviewees even understood that
part of the question.

Another variant was to ask the interviewee to give the general
solution for N eggs and M stories.

--
-Ed Falk, http://www.velocityreviews.com/forums/(E-Mail Removed)
http://thespamdiaries.blogspot.com/

arnuld
Guest
Posts: n/a

 10-25-2011
> On Sun, 23 Oct 2011 08:53:31 +0000, Willem wrote:

> If this is the puzzle I think it is, you're supposed to have two eggs,
> and the question is to determine the minimal number of drops which

My best guess, interviewer is trying to check guy's algorithmic analysis
skills

--
arnuld
http://LispMachine.Wordpress.com

Bill Reid
Guest
Posts: n/a

 10-25-2011
On Oct 24, 3:53*pm, (E-Mail Removed) (Edward A. Falk) wrote:
> In article <(E-Mail Removed)..com>,
>
> christian.bau <(E-Mail Removed)> wrote:
> >On Oct 23, 7:39*am, divya bisht <(E-Mail Removed)> wrote:
> >> Hardest Google Interview Question

>
> >>http://hardest-puzzle.blogspot.com/2...rview-question.....

>
> I would be surprised if they're still asking that one; Google tends
> to ban questions that are too widely known.
>
> These questions are asked to test to see if you can work out problems
> and to get a look into your thought process. *In my experience, the
> interviewer will generally coax you along rather than force you to
> flounder if you don't get it right away. *Of course, if you *do*
> get it right away, that's even better.
>
> >That's their hardest question? Seriously? Apart from the problem that
> >the "question" in the end is a bit unclear. The number of drops needed
> >obviously depends on something you don't know, which is the lowest
> >height that will break the egg.

>
> Question specifies that it could break anywhere from the first
> to the last floor.
>
> >A clearer question would be "which
> >strategy gives the lowest expected number of drops", given some
> >distribution of probabilities, or "which strategy produces the
> >smallest maximum number of drops".

>
> We generally asked the interviewee to optimize the worst-case
> scenario for number of drops. *If they got it easily enough,
> we'd ask what the expected number of drops was. *You'd be
> depressed to know how few interviewees even understood that
> part of the question.
>

I don't know if it's "depressing", but as usual I'm somewhat
amazed at how few "professional" programmers here know the
correct answer to the question, and all the irrelevant obfuscatory
crap they spew out to vainly try to disguise their lack of
critical thinking and knowledge of search algorithms...confusing
them with a first-day college statistics class concept of
"expectation"
is just cruel and unusual...

> Another variant was to ask the interviewee to give the general
> solution for N eggs and M stories.
>

I'm not sure I saw that in this thread, but it IS pretty
simple...but what does any of this have to do with ripping
off Sun's Java(TM) and Apple's iPhone(TM)? I mean, wouldn't
a better Google(TM) question be: what's the best way to
shoplift liquor from Rite-Aid(TM)?

---
William Ernest Reid