floor(n/2) + 1

View Allnum of num

Research Analyst Interview Bengaluru

WorldQuantAnswer## 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

7 Answers

* This post has been removed. Please see our Community Guidelines or Terms of Service for more information.*

▲

0

▼

floor(n/2) + 1

▲

21

▼

first egg, try floors at 14, 27, 39, 50, 60, 69, 77, 84, 90, 95, 99, 100

second egg then try floors in between,

then no more than 14 tries total in worst case

▲

1

▼

for n floor building answer will be

Int refers to rounding of the closest integer.

Int(sqrt(n))) - 1*Z + (IntSqrt(n) - 1) + (n - M)

where Z = 0 if n - Int(sqrt(n))^2 > 0

Z = 1 if n - Int(sqrt(n))^2 <= 0

and M is maximum integer multiple of Int(sqrt(n) <= n

▲

0

▼

50 times: 2,4,6,...,100

▲

0

▼

earlier answer 14 drops is wrong because if the floor at which egg breaks is 68, it will require 15 drops: 14 27 39 40 50 60 69 61 62 63 64 65 66 67 68

Therefore the minimum drops is 15:

drop first egg in these floors. no chance you will need to drop more that 15 times.

15 29 42 54 55 65 74 82 89 95 100

To comment on this, Sign In or Sign Up.

Would you like us to review something? Please describe the problem with this {0} and we will look into it.

Your feedback has been sent to the team and we'll look into it.

floor(n/2) + 2