Interview Question

Principal Engineer Interview

-Bangalore

Intuit

analytical- there are 50 floors in a building. You are given two balls which can break at a certain f trheight . Give a solution where you can determine the critical height at which a ball breaks. the solution should be optimised to give the least no. of tries for the worst case scenario(i.e where the ball breaks on the 50th floor only)

AnswerAdd Tags

Interview Answers

3 Answers

0

first ball --- throw it every floor from the iteration the second balls breaks second ball --- throw it every 3 or 4 or 5 floor ... When the second ball breaks, you know there are only 3 or 4 or 5 floors to check ... O (log n) complexity ... best case O(1)

Praveen on

0

i'll go with binary search procedure..since it stands a better chance

Anonymous on

0

think over !!

Anonymous on

Add Answers or Comments

To comment on this, Sign In or Sign Up.