Super Egg Drop - Problem

You are given k identical eggs and you have access to a building with n floors labeled from 1 to n.

You know that there exists a floor f where 0 <= f <= n such that:

  • Any egg dropped at a floor higher than f will break
  • Any egg dropped at or below floor f will not break

Each move, you may take an unbroken egg and drop it from any floor x (where 1 <= x <= n). If the egg breaks, you can no longer use it. However, if the egg does not break, you may reuse it in future moves.

Return the minimum number of moves that you need to determine with certainty what the value of f is.

Input & Output

Example 1 — Basic Case
$ Input: k = 1, n = 2
Output: 2
💡 Note: With only 1 egg, we must try floors sequentially: drop from floor 1, then floor 2 if it doesn't break. Worst case is 2 moves.
Example 2 — Multiple Eggs
$ Input: k = 2, n = 6
Output: 3
💡 Note: With 2 eggs and 6 floors, optimal strategy: drop from floor 3. If breaks, try floors 1,2 with remaining egg (3 total moves). If survives, drop from floor 5, then check remaining floors.
Example 3 — Many Eggs
$ Input: k = 3, n = 14
Output: 4
💡 Note: With 3 eggs, we can use more aggressive binary search strategy, requiring only 4 moves in worst case for 14 floors.

Constraints

  • 1 ≤ k ≤ 100
  • 1 ≤ n ≤ 104

Visualization

Tap to expand
Super Egg Drop: Find Critical Floor fBuilding654321Critical floor f = 3Eggs break above floor 3Eggs survive at floor 3 or below🥚🥚2 eggs availableOptimal Strategy:3 moves minimumGoal: Find floor f with minimum moves where eggs start breaking
Understanding the Visualization
1
Input
k=2 eggs, n=6 floors building
2
Strategy
Find optimal floors to test
3
Output
Minimum 3 moves needed
Key Takeaway
🎯 Key Insight: Think backwards - with t moves and k eggs, what's the maximum floors we can handle? Binary search on the answer is most efficient.
Asked in
Google 15 Microsoft 12 Amazon 8
89.0K Views
Medium Frequency
~35 min Avg. Time
2.1K Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen