Data Structures & AlgorithmsVery hardProduct Company SDE · ICPC regional
Problem: Ship packages in order (weights 4, 7, 2, 9, 5, 3, 8, 6, 1) through consecutive days, with each day's load at most a capacity C. The goal is to deliver everything in at most 4 days. What is the minimum possible capacity C?
- A. 17
- B. 14
- C. 11
- D. 12
Correct answer: B. 14
Binary search on C from max weight 9 to the total 45: C = 14 ships [4, 7, 2] [9, 5] [3, 8] [6, 1] in 4 days, while 13 needs 5. Requiring fewer than 4 days (or 3 days) gives 17, allowing 5 days gives 11, and ceil(45 / 4) = 12 ignores that packages cannot be split.
More Coding Interview Problems questions
- Problem: Count the triples of indices i < j < k in [2, 5, 1, 7, 3, 4, 6] with a[i] + a[j] + a[k] ≤ 12.
- Problem: How many integers n with 1 ≤ n ≤ 500 satisfy n mod 3 = n mod 5 ?
- Problem: A matrix of size 4×4 is filled row-wise with 1 to 16 (row 0 holds 1–4, row 1 holds 5–8, and so on). It is rotated 90 degrees…
- Problem: In the string "racecarbanana", find the number of distinct palindromic substrings of length at least 3.
- Problem: On a line of 12 cells (1–12), a robot starts at cell 1. Each second it moves to the cell i+3 if that cell is still ≤ 12 and not…
- Problem: A string is built by writing the first 15 positive integers in binary, concatenated in order (1, 10, 11, 100, ..., 1111). How…