Hacker News new | past | comments | ask | show | jobs | submit login
The Classic Two Egg Problem (interviewcake.com)
19 points by gameguy43 on Oct 15, 2014 | hide | past | favorite | 4 comments



Those hints were pleasingly helpful, they lead you right to the 'aha' moment without giving the whole answer.


[deleted]


Strange, my reaction was the opposite. If the interviewer asked me to print the minimum number of drops and my code was a single print statement of the closed form answer, I wonder what the reaction would be.

Although the posted solution process is equivalent, my solution was to use dynamic programming when I had encountered this problem first. Once you have the recursion figured out, the closed form is a few algebraic steps away. One advantage of this is that now you can also optimize for the expected case, not just the worst case.

There is hardly any code to write once you have solved it on paper (or solved it in your head if you are much smarter).

What I really liked about the post was the number of insights in the hints and how the hints are laid out gradually. I missed a lot of those, cause the moment I saw the DP I stopped thinking. It became a problem of just solving the recursion. There is always a lot of value in getting your insights about a problem.


We ask a variation of this question in our interviews. (We use lightbulbs, not eggs). I've yet to have anyone storm out yet.


On my planet, eggs will break when dropped from the 1st floor. ;-)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: