Data Structures & AlgorithmsHardProduct Company SDE · Amazon OA
Problem: Piles of bananas are [3, 6, 7, 11] and you must finish all of them within 8 hours. Each hour you eat up to k bananas from one pile (if a pile has fewer, you finish it that hour). What is the minimum integer speed k?
- A. 4
- B. 5
- C. 3
- D. 6
Correct answer: A. 4
Binary search on the speed, with the check counting ceil(pile / speed) hours. Rounding the average pile down gives a speed that is too slow.
More Coding Interview Problems questions
- Problem: Intervals [1,4], [3,8], [6,9], [10,12], [2,5] are given. How many of them contain the point 5 (endpoints included)?
- Problem: Compute (1³ + 2³ + … + 100³) modulo 1000.
- Problem: A trie stores the words "apple", "app", "apply", "ape", "banana". How many stored words start with the prefix "app" (including a…
- Problem: Subtraction game: from n stones a player may remove 1, 3 or 4 stones; the player who cannot move loses (no stones left on their…
- Problem: On the 4-cycle C4 (vertices 0-1-2-3-0), a walker starts at 0 and takes exactly 3 steps, each to an adjacent vertex. How many…
- Problem: The array [7, 3, 9, 1, 5] is processed by a selection that finds the position of the maximum, removes it, and repeats. The…