199. Super Egg Drop
You are given n identical eggs and a building with k floors numbered from 1 to k.
There exists an unknown floor f such that:
- Any egg dropped from a floor higher than f will break.
- Any egg dropped from f or below will not break.
- Your goal is to determine the value of f using the minimum number of egg drops in the worst-case scenario.
You may assume:
- An egg that survives a fall can be reused.
- A broken egg must be discarded.
- All eggs behave the same way.
- If an egg breaks at a floor, it would break at any higher floor.
- If an egg survives a floor, it would survive any lower floor.
Example 1:
Input: n = 2, k = 36
Output: 8
Explanation: Minimum 8 moves are needed in the worst-case using binary + linear strategy.
Example 2:
Input: n = 1, k = 36
Output: 36
Explanation: With 1 egg, worst-case is to test all floors linearly from 1 to 36.
Now Your Turn!
Pick the correct output for the given inputInput: n = 3, k = 14
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= n <= 1000 (number of eggs)
- 1 <= k <= 1000 (number of floors)