VOOZH about

URL: https://www.geeksforgeeks.org/aptitude/puzzle-set-35-2-eggs-and-100-floors/

⇱ Puzzle - 2 Eggs and 100 Floors - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Puzzle - 2 Eggs and 100 Floors

Last Updated : 13 Apr, 2026

You are given a building with 100 floors and two eggs. There exists a certain floor, called the critical floor, such that an egg dropped from this floor or any floor below it does not break, while an egg dropped from any floor above it will break.

Conditions

  • You have only two eggs.
  • A broken egg cannot be used again.
  • An unbroken egg can be reused.
  • All eggs behave identically.
  • If an egg breaks on a certain floor, it will also break from all higher floors.
  • If an egg survives a drop, it will also survive all lower floors.

Determine the highest safe floor in a 100-floor building using two eggs, while minimising the maximum number of drops required in the worst case.

👁 2_eggs_and_100_floors

Check if you were right - full answer with solution below.

Solution:

To minimise the number of drops in the worst case, with 2 eggs and 100 floors, we cannot use binary search because if one egg breaks early, we are left with only one egg and many floors to check.

The idea is to balance the number of attempts in every situation. We start by dropping the first egg from a floor x.

  • If the egg breaks, we check all floors below it one by one using the second egg.
  • If the egg does not break, we move up with smaller steps each time: first x floors, then x-1, then x-2, and so on.

This ensures that the total number of attempts never exceeds x.

To cover all 100 floors, we use the sum of decreasing steps:

x + (x − 1) + (x − 2) + ... + 1 ≥ 100

This is the sum of first x natural numbers:

x(x + 1) / 2 ≥ 100

Now solve:

x(x + 1) ≥ 200

Try values:

13 × 14 = 182 (less than 200, not enough)
14 × 15 = 210 (greater than 200, works)

So, x = 14 (approx.)

Now compute the dropping sequence:

Start from 14
Next: 14 + 13 = 27
Next: 27 + 12 = 39
Next: 39 + 11 = 50
Next: 50 + 10 = 60
Next: 60 + 9 = 69
Next: 69 + 8 = 77
Next: 77 + 7 = 84
Next: 84 + 6 = 90
Next: 90 + 5 = 95
Next: 95 + 4 = 99
Next: 99 + 1 = 100

So the sequence is:
14, 27, 39, 50, 60, 69, 77, 84, 90, 95, 99, 100

Thus, by following this strategy, we can determine the highest safe floor in at most 14 drops, which is the optimal solution in the worst case.
Read more: Egg Dropping Puzzle (k eggs, n floors).

Comment