There are** E eggs (= allowed egg breaks)**, a building with F floors [1 ≥ F] anda special floor S [0 ≤ S ≤ F] - any unbroken egg dropped at a floor higher than Swill break and any egg dropped at or below this floor will not break.

Given that an unbroken egg can be dropped from any floor, what is the minimum number of **egg drops D [1 ≤ D ≤ F] **neededin order to find Sin the worst case?

Input1: E =1 , F=1 | Output1: D=1

Input2: E =1 , F=2 | Output2: D=2

Input3: E =1 , F=7 | Output3: D=7

Input4: E =2 , F=7 | Output4: D=4

Input5: E =3 , F=7 | Output5: D=3

Common confusion points:

  • What is “Worst case”? It means that egg breaking must happen only when the search range from top to bottom is exhausted.
  • What is “floor0” in the range for special floor? Treat it as a basement where egg drop isn’t allowed but can be used for reference. Example: S=0 incase the the egg breaks on floor 1 which would mean any drop above floor 0 will result in a break.

#dynamic-programming #leetcode #coding #java #algorithms

How to Solve Super Egg Drop Problem with Dynamic Programming
7.25 GEEK