Calculate area, flush probability, egg drops
Company: Talroo
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Online Assessment
Overview: This multipart question evaluates spatial and analytic geometry for exact area computation, combinatorial counting and probability for card-hand enumeration, and discrete optimization and worst-case algorithmic analysis as exemplified by the two-egg drop problem.
Constraints
- 1 <= n <= 10^12
- You may adapt your next drop based on previous outcomes.
- At most two marbles may break (equivalent to two eggs).
- Return the minimum number of drops in the worst case.
- Target time complexity: O(1) or O(log n).
- Use 64-bit integer arithmetic; avoid floating-point rounding.
Hints
- With two breakable marbles, the optimal strategy uses decreasing step sizes: t, t-1, t-2, ...
- You can cover t(t+1)/2 floors in t drops in the worst case.
- Find the smallest integer t such that t(t+1)/2 >= n; use integer square root to avoid floating-point issues.