820. Egg Drop Problem (Recursive + Memo)

HardRecursionRecursion

Given k eggs and n floors, find the minimum number of trials needed in the worst case to determine the critical floor. Use the binary-search + combinatorial approach.

Input: Two integers k (eggs) and n (floors).

Output: Integer.

Examples

Example 1
Input: 1, 10
Output: 10
Explanation: With 1 egg, must try each floor.
Example 2
Input: 2, 10
Output: 4
Explanation: 4 trials suffice with 2 eggs, 10 floors.
Example 3
Input: 2, 6
Output: 3
Explanation: 3 trials.

Constraints

Asked by

AmazonGoogleMicrosoftMetaAdobe
Solve this problem in the editor →