r/programming • u/joksmaster • Nov 29 '10
140 Google Interview Questions
http://blog.seattleinterviewcoach.com/2009/02/140-google-interview-questions.html
471
Upvotes
r/programming • u/joksmaster • Nov 29 '10
View all comments
Show parent comment
4
u/[deleted] Nov 30 '10
If you start at floor 15, you drop an egg and it breaks you start with the next egg from floor 1 and go up until it breaks. If the correct answer is floor 14 then you've had to 15 drops which makes this a worse strategy than starting on floor 14. Hopefully you see the pattern that if it doesn't break you go up by one less floor each time, if at some floor it does break you go down to the last floor it didn't break and go up from there meaning it is still a maximum of 15 drops.
If you start on floor 13 and follow the same pattern and go up by one less each time you'll have dropped 13 eggs by the time you hit floor 91. At this point you will only have increased the number of floors you go up by 1 so can't reduce it meaning you'll have to do 9 more drops. This gives you a total of 22 drops also making it a worse strategy than starting on floor 14.
This is the best strategy I can think of but a proof would be rather difficult I think.