Gamified challenge · 2-D dynamic programming
A tower has floors 1 to floors. Somewhere there is a critical floor f (between 0 and floors): an egg dropped from any floor up to f survives and can be reused, and an egg dropped from any floor above f breaks and is gone. You have eggs identical eggs (at least 1) and don't know f.
Write minDrops(eggs, floors) (Python min_drops) that returns the fewest drops that are guaranteed to find f in the worst case, whatever f turns out to be. You plan each drop after seeing the earlier results.
Example: with 2 eggs and 10 floors the answer is 4: drop from floors 4, 7, 9 and 10 until the first egg breaks, then walk up one floor at a time with the second egg.
This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.
Sign in with Google