Super Egg Drop
With k eggs and n floors, find the minimum number of moves that guarantees locating the critical floor.
Intuition
Flip the question: instead of “how many moves for n floors?”, ask “how many floors can m moves and k eggs cover?” One drop splits the world: if the egg breaks you have m−1 moves and k−1 eggs for the floors below; if it survives, m−1 moves and k eggs for the floors above. So f(m,k) = f(m−1,k−1) + f(m−1,k) + 1 — and the answer is the smallest m with coverage ≥ n.
Approach
Why the naive DP is slow
dp[k][n] = 1 + min over pivot x of max(dp[k−1][x−1], dp[k][n−x]) is O(k·n²) — too slow for n up to 10⁴ without a monotonic/binary-search optimization.
Invert to coverage
f(m,k): max floors decidable in m moves with k eggs. The drop floor contributes 1, breaks send you down (f(m−1,k−1) floors), survives send you up (f(m−1,k) floors). Sum them.
March m upward
Keep a 1-D array over eggs, incrementing m until f(m,k) ≥ n. Coverage grows fast (binomial sums — nearly exponential in m), so m stays small.
Solution & live demo
Edge cases
Must scan bottom-up: coverage grows by 1 per move — answer n.
One drop decides — answer 1.
With k ≥ log₂n eggs it degenerates to binary search: ⌈log₂(n+1)⌉ moves.