Interview Question

Senior Software Engineer Interview

-Bangalore

Goldman Sachs

Classix 2 eggs problem . * You are given 2 eggs. * You have access to a 100-storey 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 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process

Answer

Interview Answers

5 Answers

2

9.8m/sec^2 is the acceleration due to gravity, not velocity. No falling object can ever achieve terminal velocity, as you incorrectly stated. Secondly, although your answer is correct, your formula is wrong. The general form is ceiling[ (sqrt(8n+1)-1) / 2], with n = # of stories.

Dan Loewenherz on

1

Lets assume you divide the floors into y partitions of size x each. The least value of y gives the best solution: here, x^y +x-1 =99 for the worst case best satisfactory ans.

Ashish on

1

use first egg to reduce the problem half size and then use second egg progressively to find answer. 100/2 then 50/2 then 25/2 then 13/2 then 7/2 then 4/2 then2/2 but while you start start dropping in reverse order from first, second... Otherwise simple mathematical inequality eqn q(q+1)/2>=100 will solve the problem.

Alchemist on

2

use first egg to reduce the problem half size and then use second egg progressively to find answer. 100/2 then 50/2 then 25/2 then 13/2 then 7/2 then 4/2 then2/2 but while you start start dropping in reverse order from first, second...

Alchemist on

7

This is a BS question to begin with bc gravity will max the egg's speed out at 9.8m per second, whether it be the 1st or 100th floor. BUT, I know what they are intending to ask... The answer is 14. n(n+1)/2

matt on

Add Answers or Comments

To comment on this, Sign In or Sign Up.