Why it matters

Egg drop is interview classic. Understanding shapes tricky DPs.

Advertisement

The architecture

dp[k][n] = min trials worst case.

Drop from floor x: break or not.

Egg drop DPk eggsn floorsDrop at xbreak or notRecurseworst caseAlternative: dp[k][trials] = max floors covered; O(kn) via inversion
Egg drop.
Advertisement

How it works end to end

dp[k][n] = 1 + min over x of max(dp[k-1][x-1], dp[k][n-x]).

Inversion trick: dp[k][t] = max floors for k eggs + t trials.

Binary search x with quadrangle.