Weighted Round-Robin Seller Task Scheduler
Updated
Problem statement
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
RECEIVEorPROCESS. - Each receive uses a globally unique nonempty task ID, a nonempty seller ID, a tier of
VIPorSTANDARD, and priority1,2, or3. - Every receive for the same seller uses the same tier.
- The combined length of all task and seller IDs is at most
500000.
More ByteDance Onsite Interview questions
- Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Largest Rectangle in HistogramPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Reverse Linked ListPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Search a Row- and Column-Sorted MatrixONSITE INTERVIEW · Seen Nov 2026
- Alien DictionaryPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lexicographically Smallest Topological OrderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Implement Multi-Head AttentionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Dynamic Median with Additions and DeletionsONSITE INTERVIEW · Seen Oct 2026
- Serialize and Deserialize a String Key-Value StoreONSITE INTERVIEW · Seen Oct 2026
- Binary Tree Maximum Path SumONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Durable Work Queue OperationsOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
- Blocking Connection Pool Operation TraceGoogle · ONSITE INTERVIEWGoogle interview questions
- Matching Engine with Order CancellationIMC Trading · ONSITE INTERVIEWIMC Trading interview questions
- Concurrent Buffered File LoggerDatabricks · ONSITE INTERVIEWDatabricks interview questions
- Priority Message BufferAmazon · ONSITE INTERVIEW
- Recent Hit CounterAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
- Metric Counter with a Fake ClockSnap Inc. · ONSITE INTERVIEWSnap Inc. interview questions
- Per-Client Sliding-Window Rate LimiterNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions
- Article Vote TrackerRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
- Dynamic Least-Loaded Job DispatcherCresta · PHONE SCREENCresta interview questions
ByteDance interview experiences
- ByteDance TikTok USDS SWE Intern Interview: 1 Experience
- ByteDance MLE New Grad Interviews: 1 Experience
- ByteDance Security SRE Intern Phone Screens: 1 Experience
- ByteDance USDS New Grad SWE Phone Screen: 1 Experience
- ByteDance New Grad Data Engineer Video Interviews: 1 Experience
- ByteDance Trust & Safety Research Scientist Intern: 1 Experience