Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Egg Dropping Puzzle

HardPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Egg Dropping Puzzle. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Solve the egg dropping puzzle with two eggs and the given number of floors.

Implement a function that returns the minimum number of drops required in the worst case to determine the highest safe floor when exactly two eggs are available. An egg breaks when dropped above the critical floor and cannot be reused. The function receives a nonnegative integer number of floors and returns an integer.

Constraints

  • 0 <= floors <= 10^9
  • Exactly two eggs are available
  • Return the minimum number of drops in the worst case
  • The critical floor may be any floor from 0 through floors

Function Signature

def two_egg_drop(floors):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output