Python data engineering interview problem. Difficulty: advanced. Pattern: Streaming. About 20 minutes. Part of the Pro drill bank.
A task scheduler should pick workers in weighted round-robin so a worker with twice the weight gets roughly twice the jobs.
Simulate weighted round-robin assignment for a number of steps.
Input: weighted_round_robin([('a', 2), ('b', 1)], 5) Output: ['a', 'a', 'b', 'a', 'a'] This input follows the stated rules and produces this output.
Topics: lakebench, python, queue.
More Python interview questions · All interview problems · Learn data engineering
Interview-style drill: Simulate a scheduler that cycles through workers, giving each a number of turns proportional to its weight.
Simulate weighted round-robin assignment for a number of steps.