← Questions

Assign tasks to servers by weighted load with expiry

0
StripeCodingLast asked Nov 2023

Servers each have a maximum load. Tasks arrive in time order, each with a weight and a time to live. Before placing a task, release every earlier task whose time has run out. Place the task on the server with the smallest current load that can still fit its weight, breaking ties by server name, and report where each task went, or that no server could take it. Discuss how a heap of expiry times keeps this efficient.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding