Job scheduling with gaps
You are given the workload as counts: counts[i] is how many jobs of type i must run. Each job takes one slot, you may order jobs freely, and two jobs of the same type must be separated by at least `gap` slots (slots may be left idle to satisfy this). Return the minimum total number of slots needed to finish everything. An empty counts list needs 0 slots. Example: counts = [3, 1], gap = 2 gives 7 — one optimal layout is A B _ A _ _ A.
Implement
min_total_slots(counts: list[int], gap: int) → intExamples
in
[[3,1],2]out7What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 16 min
solution.py
InputExpectedGot
[[3,1],2]7not run yetsample