FastPrepTwo-Egg Dropping
Problems/Two-Egg Dropping

Two-Egg Dropping

NVIDIA logoNVIDIA● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The named two-egg puzzle matches at about 85%. Its threshold behavior, worst-case objective and floor bounds use the conventional practice rules omitted from the report.

A building has floors 1 through n. Some unknown floor f is the highest safe floor, where 0 <= f <= n. You have two identical eggs. An egg dropped from a floor above f breaks. An egg dropped from floor f or lower does not break, and you can drop it again. A broken egg cannot be used again.

You may choose each drop based on what happened in the earlier drops. Return the smallest number of drops that always lets you find f, even in the worst case.

Function

twoEggDrop(n: int) → int

Examples

Example 1

n = 1return = 1

A single drop from the only floor shows whether f is 0 or 1, so one drop is enough.

Example 2

n = 6return = 3

Drop the first egg from floor 3, then 5, then 6, moving up only while it survives. If it breaks, use the second egg on the untested floors below it, one at a time from the lowest. Every case needs at most three drops.

Example 3

n = 50return = 10

Nine drops can check at most 45 floors, which is too few for this building. Ten drops can check 55 floors, which is enough, so the answer is ten.

Constraints

  • 1 <= n <= 1000.
  • One fixed floor f decides every drop, so a drop from the same floor always gives the same result.

More NVIDIA Onsite Interview questions

  • Check Endianness Of A Byte ArrayONSITE INTERVIEW · Seen Sep 2026
  • Implement MallocONSITE INTERVIEW · Seen Sep 2026
  • Implement PrintfONSITE INTERVIEW · Seen Sep 2026
  • Merge Two Arrays Into Sorted OrderONSITE INTERVIEW · Seen Sep 2026
  • Middle Node Of A Linked ListONSITE INTERVIEW · Seen Sep 2026
  • Ping Reply TrackingONSITE INTERVIEW · Seen Sep 2026
  • Reverse A StringONSITE INTERVIEW · Seen Sep 2026
  • Maximum Fish in a GridONSITE INTERVIEW · Seen Sep 2024
  • Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
  • First Register Overflow TickONSITE INTERVIEW · Seen May 2024

Similar questions at other companies

  • Dice-Walk Winning ProbabilityGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Integer BreakAmazon · ONSITE INTERVIEW
  • Knight Probability in ChessboardGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
  • Count Staircases with Strictly Increasing StepseBay · ONSITE INTERVIEWeBay interview questions
  • Count Divisible Power SumsGoodScore · ONSITE INTERVIEW
  • Tile a Three-Row Board with DominoesJP Morgan Chase · ONSITE INTERVIEWJP Morgan Chase interview questions
  • Best Expected Result in Simplified BlackjackHudson River Trading · ONSITE INTERVIEWHudson River Trading interview questions
  • Every Result of Grouping an ExpressionC3.ai · ONSITE INTERVIEWC3.ai interview questions
  • Split a Number into Non-Decreasing GroupsExpedia · OA · ONSITE INTERVIEWExpedia interview questions
  • Fibonacci NumberMicrosoft · ONSITE INTERVIEWMicrosoft interview questions

NVIDIA interview experiences

  • NVIDIA Full-Time SWE Onsite Scheduling: 1 Experience
  • NVIDIA OA: What It Tests (2026)
  • NVIDIA DevOps, QA and Infra Intern Interviews: 12 Experiences
  • NVIDIA Ignite Internship OA Experience
  • NVIDIA Software Intern Interview Questions: 9 Experiences
  • NVIDIA Ignite SWE Intern OA Questions: 6 Experiences
All NVIDIA interview questionsSee NVIDIA hiring insights
Saved
class Solution {
    public int twoEggDrop(int n) {
        // Write your code here.
    }
}
Checking account…