Question
A thread pool with `workers` worker threads (0..workers-1) processes a queue of tasks one unit of work at a time using a least-loaded assignment policy. Tasks arrive in order with cost costs[i]. Each task is assigned to the worker that currently has the smallest total assigned cost; ties are broken by the smaller worker id. Return a list `load` of length `workers` where load[w] is the total cost assigned to worker w after all tasks are placed.
assign_loads(workers: int, costs: list[int]) → list[int][2,[3,1,2,4]]out[7,3]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.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.