Weighted Round-Robin Seller Task Scheduler
Reported by candidates from ByteDance's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
ByteDance reported this one in September 2026, and the title sounds friendlier than it is. It's a simulation with a queue of sellers, a priority structure inside each seller, and a quota counter that has to survive between PROCESS calls. If your OA invite lands this week, expect the bugs to hide in the rotation rules, not the data structures. A seller leaves when empty, rejoins at the back, and a VIP can burn two dispatches in one turn. Get one transition wrong and the sample passes while hidden tests fail. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment.
The problem
Simulate a seller task scheduler over a finite sequence of RECEIVE and PROCESS operations. A receive supplies a unique task ID, seller ID, fixed seller tier (VIP or STANDARD), and priority from 1 through 3. Within one seller, smaller priority numbers are processed first and equal priorities are FIFO. Active sellers rotate in first-activation round-robin order. A VIP seller may process up to two tasks in one turn; a standard seller may process one. A seller whose turn quota expires while work remains moves to the back. A seller whose queue becomes empty leaves the rotation and rejoins at the back if new work arrives. For each PROCESS, return sellerId:taskId, or the empty string if no task is waiting. Fields paired with PROCESS are ignored. Function scheduleSellerTasks(operations: String[], taskIds: String[], sellerIds: String[], sellerTiers: String[], priorities: int[]) → String[] Examples Example 1 operations = ["RECEIVE","RECEIVE","RECEIVE","RECEIVE","PROCESS","PROCESS","PROCESS","PROCESS"] taskIds = ["v1","v2","v3","s1","","","",""] sellerIds = ["V","V","V","S","","","",""] sellerTiers = ["VIP","VIP","VIP","STANDARD","","","",""] priorities = [1,2,3,1,0,0,0,0] return = ["V:v1","V:v2","S:s1","V:v3"] The VIP seller receives two consecutive dispatches, the standard seller receives one, then the VIP seller returns. Example 2 operations = ["RECEIVE","RECEIVE","RECEIVE","RECEIVE","PROCESS","PROCESS","PROCESS","PROCESS"] taskIds = ["a1","a2","b1","b2","","","",""] sellerIds = ["A","A","B","B","","","",""] sellerTiers = ["STANDARD","STANDARD","STANDARD","STANDARD","","","",""] priorities = [1,1,1,1,0,0,0,0] return = ["A:a1","B:b1","A:a2","B:b2"] Two standard sellers alternate until both queues are empty. Constraints 1 <= operations.length <= 100000; all five arrays have equal length. Each operation is RECEIVE or PROCESS. Each receive uses a globally unique nonempty task ID, a nonempty seller ID, a tier of VIP or STANDARD, and priority 1, 2, or 3. Every receive for the same seller uses the same tier. The combined length of all task and seller IDs is at most 500000.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The structure is a global queue of active sellers plus a per-seller priority queue keyed by (priority, arrival counter). Keep a map from seller ID to its heap, an active flag, and a tier. Track the current turn's remaining quota for the seller at the front. On PROCESS: if the queue is empty, emit the empty string. Otherwise pop the best task from the front seller, decrement quota, and emit sellerId:taskId. Then decide. If the seller's heap is empty, remove them from rotation and reset quota state. Else if quota hit zero, move them to the back. The classic pitfall is the stale quota: a VIP who processed one task and emptied out must start fresh at two when they rejoin. Another is a seller receiving work while still at the front mid-turn, which must not requeue them. StealthCoder is the hedge if the state machine tangles live, but write the transitions down first.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Weighted Round-Robin Seller Task Scheduler cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass ByteDance's OA.
ByteDance reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Weighted Round-Robin Seller Task Scheduler FAQ
What's the trick in the ByteDance weighted round-robin scheduler?+
Separate the two structures. A queue holds active sellers in activation order, and each seller owns a min-heap keyed by priority then arrival index. Keep a turn counter for the front seller only. Every PROCESS pops one task, then decides whether the seller stays, goes to the back, or leaves.
What edge case breaks naive solutions?+
Quota reset on rejoin. A VIP who processes one task and empties their queue leaves the rotation. When new work arrives, they rejoin at the back with a fresh quota of two. Carrying over the old count is the usual hidden-test failure.
How do I handle a RECEIVE for a seller who is already active?+
Just push the task into that seller's heap. Don't touch their position in the rotation and don't reset their quota. Only a seller with an empty queue and no active flag gets appended to the back of the seller queue.
What complexity should I aim for with 100000 operations?+
O(n log n) total. Each RECEIVE is a heap push, each PROCESS is a heap pop plus O(1) queue moves. Use an arrival counter as the tiebreaker for FIFO within equal priority. Don't scan sellers on every call or you'll time out.
How do I prepare for this in 48 hours?+
Write the simulation from scratch twice. Trace both examples by hand, then add cases: empty PROCESS, VIP with one task, a seller rejoining after emptying, and mixed priorities. Focus on the state transitions after each pop, since that's where the bugs live.