FastPrepTwo Eggs: Minimum Worst-Case Drops
Problems/Two Eggs: Minimum Worst-Case Drops

Two Eggs: Minimum Worst-Case Drops

Apple logoApple● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Apple full-time onsite interview. The puzzle with two eggs and 100 floors, and the strategy of making each jump one floor shorter, are about 85% the same as the report. We chose these: how the breaking threshold works, that the answer is the best worst case, what to return for zero floors, and a general limit on the number of floors.

You have two identical eggs and a building with floors numbered 1 through floors. There is a hidden threshold t, where 0 <= t <= floors. An egg dropped from floor t or any lower floor survives. An egg dropped from any floor above t breaks.

Once an egg breaks, you cannot use it again. An egg that survives can be dropped again. You pick each next floor based on what happened in earlier drops, and you stop once you know t for sure. Return the smallest number of drops that is always enough to find t, no matter which threshold it is.

With zero floors, you already know the threshold, so the answer is zero. This is the well-known puzzle with two eggs and 100 floors, but for any number of floors.

Function

twoEggDrops(floors: int) → int

Examples

Example 1

floors = 100return = 14

Make the first drop from floor fourteen. Each time the egg survives, jump up one floor less than the last jump. If the first egg breaks, check the floors in that gap one by one with the second egg. This way fourteen drops can cover 14 + 13 + ... + 1 = 105 floors, which is enough. Thirteen drops cover only 91 floors, which is too few. So the answer is fourteen.

Example 2

floors = 3return = 2

Drop the first egg from floor two. If it breaks, t is zero or one, so drop the other egg from floor one to tell which. If it survives, t is two or three, so drop the same egg from floor three. Either way you know t after two drops. One drop is not enough, because it cannot tell four possible thresholds apart. So the answer is two.

Constraints

  • 0 <= floors <= 10^9.

More Apple Onsite Interview questions

  • Topological OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Merge IntervalsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • FIFO Mutex Operation TraceONSITE INTERVIEW · Seen Oct 2026
  • Implement Hit CounterPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Parse Nested HTML into a TreeONSITE INTERVIEW · Seen Oct 2026
  • Thread-Safe Concurrent Linked ListONSITE INTERVIEW · Seen Sep 2026
  • Palindrome Match PercentageONSITE INTERVIEW · Seen Sep 2026
  • Binary Tree Nodes at Distance KONSITE INTERVIEW · Seen Aug 2026
  • BST to Sorted Circular Doubly Linked ListONSITE INTERVIEW · Seen Aug 2026

Similar questions at other companies

  • Random Pick with Weight Using Recorded DrawsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Koko Eating BananasTekion · ONSITE INTERVIEWTekion interview questions
  • Koko Eating BananasAmazon · ONSITE INTERVIEW
  • Maximum Supplier ProfitExpedia · ONSITE INTERVIEWExpedia interview questions
  • First Register Overflow TickNVIDIA · ONSITE INTERVIEWNVIDIA interview questions
  • Find a Function Root by BisectionJP Morgan Chase · ONSITE INTERVIEWJP Morgan Chase interview questions
  • Integer Square RootMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • K-th Amount a Payout Machine Can GiveRippling · ONSITE INTERVIEWRippling interview questions
  • Integer Square Root with Error ChecksBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Server Upgrade PlanningWells Fargo · OAWells Fargo interview questions

Interview reports that mention this question

  • Apple India SWE New Grad Interviews: 5 Experiences

Apple interview experiences

  • Apple SWE Phone Screen: Subarray Products: 1 Experience
  • Apple New Grad SWE Java, Coding and Manager Rounds: 1 Experience
  • Apple AI Coding and Related Interviews: 17 Experiences
  • Apple New Grad SWE Phone Screens: 12 Experiences (Part 3 of 3)
  • Apple New Grad SWE and Embedded: 16 Experiences (Part 2 of 3)
All Apple interview questionsSee Apple hiring insights
Saved
class Solution {
    public int twoEggDrops(int floors) {
        // Write your solution here.
    }

}
Checking account…