Question
Super Egg Drop
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 on a floor higher than f will break, and any egg dropped at or below the floor f will not break.
With 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 f is.
Input
You don't need to read inputs or print anything. Complete the function superEggDrop() that takes two integers representing n and k and returns an integer representing the minimum number of moves that you need to determine with certainty what the value of f is.
Custom Input:
The first line in the input contains two space-separated integers n and k.
Constraints:
1 <= k <= 100
1 <= n <= 104
Custom Input:
The first line in the input contains two space-separated integers n and k.
Constraints:
1 <= k <= 100
1 <= n <= 104
Output
Return the minimum number of moves that you need to determine with certainty what the value of f is.
Example
Input:
1 2
Output:
2
Explanation:
k = 1, n = 2
Drop the egg from floor 1. If it breaks, we know that f = 0.
Otherwise, drop the egg from floor 2. If it breaks, we know that f = 1.
If it does not break, then we know f = 2.
Hence, we need at minimum 2 moves to determine with certainty what the value of f is.
1 2
Output:
2
Explanation:
k = 1, n = 2
Drop the egg from floor 1. If it breaks, we know that f = 0.
Otherwise, drop the egg from floor 2. If it breaks, we know that f = 1.
If it does not break, then we know f = 2.
Hence, we need at minimum 2 moves to determine with certainty what the value of f is.