Fundamentals 8 min read

Master the Classic 2‑Egg 100‑Floor Problem: Optimal Strategies Explained

This article explains the classic two‑egg, 100‑floor interview puzzle, analyzes why it became a staple, and walks through four solution approaches—from a naïve linear method to binary search and a balanced partition strategy—culminating in a mathematically derived optimal method that never exceeds fourteen drops.

NiuNiu MaTe
NiuNiu MaTe
NiuNiu MaTe
Master the Classic 2‑Egg 100‑Floor Problem: Optimal Strategies Explained

Problem Overview

In the classic interview puzzle you have two eggs and a 100‑story building; you must determine the highest floor from which an egg can be dropped without breaking using the minimum number of throws.

Assumptions

Unbroken eggs can be reused.

Both eggs have identical strength.

Solution 1 – Linear Search

With a single egg you would start from the first floor and go up one floor at a time, which in the worst case requires 100 drops.

Solution 2 – Binary Search

Using two eggs you might try the 50th floor, then halve the interval, but if the first egg breaks early you revert to linear search, leading to up to 50 drops.

Solution 3 – Balanced Partition

Divide the 100 floors into decreasing blocks (e.g., 14, 13, …, 1). Drop the first egg at the top of each block; when it breaks, use the second egg to linearly search within that block. This guarantees at most 14 drops.

Derivation

Let the first block contain X floors, the next X‑1, and so on. We need X+(X‑1)+…+1 ≥ 100, i.e., X(X+1)/2 ≥ 100. The smallest integer X satisfying this is 14.

Thus the blocks are 1‑14, 15‑27, 28‑39, …, and the first egg is dropped at floors 14, 27, 39, 50, 60, 69, 77, 84, 90, 95, 99, 100. The second egg then searches the remaining floors of the block where the first egg broke.

Conclusion

This “subtle balance” method ensures the total number of drops never exceeds 14, providing an optimal strategy for the 2‑egg 100‑floor problem.

OptimizationalgorithmBinary Searchegg-drop
NiuNiu MaTe
Written by

NiuNiu MaTe

Joined Tencent (nicknamed "Goose Factory") through campus recruitment at a second‑tier university. Career path: Tencent → foreign firm → ByteDance → Tencent. Started as an interviewer at the foreign firm and hopes to help others.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.