Skip to content

Practice Egg Drop With 2 Eggs and N Floors

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1884
LeetCode Problem

Egg Drop With 2 Eggs and N Floors

Problem Statement

You are given two identical eggs and you have access to a building with n floors labeled from 1 to n. You know that there exists a floor f where 0 <= f <= n such that any egg dropped at a floor higher than f will break, and any egg dropped at or below floor f will not break. In each move, you may take an unbroken egg and drop it from any floor x (where 1 <= x <= n). If the egg breaks, you can no longer use it. However, if the egg does not break, you may reuse it in future moves. Return the minimum number of moves that you need to determine with certainty what the value of f is.

Source: Egg Drop With 2 Eggs and N Floors on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 2
Output
2

# Example 2

Input
n = 100
Output
14

Constraints

1 <= n <= 1000

Related LeetCode Problems

Practice more problems similar to Egg Drop With 2 Eggs and N Floors.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.