Data Structures & AlgorithmsVery hardProduct Company SDE · ICPC regional
Problem: The egg-dropping puzzle with 2 eggs and a 10-floor building: what is the minimum number of drops needed in the worst case to find the highest safe floor (or prove none is safe)?
- A. 5
- B. 3
- C. 6
- D. 4
Correct answer: D. 4
The worst-case DP splits floors so that a breaking egg leaves a bounded search. With two eggs, the optimal first drop skips floors, so a linear scan from floor 1 is too slow.
More Coding Interview Problems questions
- Problem: How many ways can 10 be made using coins {1, 2, 5} where order does not matter (combinations of coin counts)?
- Problem: On a 3×3 matrix [[9,9,4],[6,6,8],[2,1,1]], a strictly increasing path moves up, down, left or right between adjacent cells with…
- Problem: The Collatz sequence starts at n = 27 and repeatedly applies: n → n/2 if n is even, n → 3n+1 if n is odd, until n = 1. How many…
- Problem: For the same Collatz process starting at n = 27, what is the largest value that appears in the sequence?
- Problem: The digital root of a positive integer is obtained by repeatedly summing its decimal digits until a single digit remains. What is…
- Problem: How many integers n with 1 ≤ n ≤ 1000 have decimal digits summing to exactly 10?