Question DSA-SRCH-0065
HardWhat is the output of this code?
def min_days(w, D):
lo, hi = max(w), sum(w)
while lo < hi:
cap = (lo + hi) // 2
days, load = 1, 0
for x in w:
if load + x > cap: days += 1; load = 0
load += x
if days <= D: hi = cap
else: lo = cap + 1
return lo
print(min_days([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 5))
- A.
11
- B.
55
- C.
Sign up free to see the answer and a step-by-step explanation.