Super Egg Drop Hard 0 attempts
LeetCode ↗

Super Egg Drop

Hard Dynamic ProgrammingMemoization LeetCode

Given k eggs and n floors, find the minimum number of moves to determine the critical floor where an egg breaks.

Example: k=2, n=6 → Output: 3

Sample Input
Sample Output
Constraints
  • 1 <= k <= 100
  • 1 <= n <= 10^4
Test Cases
Case 1
Args: [2,6] Expected: 3
Case 2
Args: [1,2] Expected: 2

DP: Moves-based approach

dp[m][k] = max floors checkable with m moves and k eggs.

function superEggDrop(k, n) {
  const dp = Array.from({length:n+1}, ()=>Array(k+1).fill(0));
  let m = 0;
  while (dp[m][k] < n) {
    m++;
    for (let j = 1; j <= k; j++) dp[m][j] = dp[m-1][j-1] + dp[m-1][j] + 1;
  }
  return m;
}

Time: O(kn) | Space: O(kn)

Saved in this browser only. Private to you.

JavaScript