Job scheduling with gaps
Your task
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.
Examples
min_total_slots(counts: list[int], gap: int) -> intExample 1
Input
min_total_slots([3, 1], 2)Output
7