Tap here to switch tabs
Problem
Submissions

Problem: Egg Drop With 2 Eggs and N Floors

med
30 min
Try to solve the Egg Drop With 2 Eggs and N Floors problem.

Statement

You are given 22 identical eggs and access to a building with n floors numbered from 11 to n.

There exists some floor f where 0≤0 \leq f ≤\leq n such that any egg dropped from a floor higher than f will break, and any egg dropped from floor f or below will not break.

In each move, you can take an unbroken egg and drop it from any chosen floor x where 1≤1 \leq x ≤\leq n. If the egg breaks, you can no longer use it. If the egg does not break, you can reuse it in subsequent moves.

Return the minimum number of moves required to determine the value of f with certainty in the worst case.

Constraints:

  • 1≤1 \leq n ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Egg Drop With 2 Eggs and N Floors

med
30 min
Try to solve the Egg Drop With 2 Eggs and N Floors problem.

Statement

You are given 22 identical eggs and access to a building with n floors numbered from 11 to n.

There exists some floor f where 0≤0 \leq f ≤\leq n such that any egg dropped from a floor higher than f will break, and any egg dropped from floor f or below will not break.

In each move, you can take an unbroken egg and drop it from any chosen floor x where 1≤1 \leq x ≤\leq n. If the egg breaks, you can no longer use it. If the egg does not break, you can reuse it in subsequent moves.

Return the minimum number of moves required to determine the value of f with certainty in the worst case.

Constraints:

  • 1≤1 \leq n ≤1000\leq 1000