Problem Β· Heap
Worker Assignment β Skills and Account Affinity
Learn this problemProblem statement
Assign support tasks to workers in input order.
Input
workers:"name,specialty".tasks:"id,duration,accountId,skills", whereskillsis a|-separated set of acceptable specialties.
For each task:
- Keep workers whose specialty appears in the task's skills.
- If any eligible worker has previously handled the same account, restrict candidates to those workers.
- Choose the candidate with the lowest accumulated workload; break ties by earlier position in
workers.
After assignment, add the task duration to the worker's workload and record that the worker has handled the account. If no worker has a required specialty, skip the task. Return successful assignments as "taskId:worker" in task order.
Practice sequence
- Part 1: balance workload
- Part 2: add specialties.
- Part 3: add account affinity (current).
Function
assignTasksAdvanced(workers: String[], tasks: String[]) β String[]Examples
Example 1
workers = ["Alice,payments","Bob,risk","Cara,payments"]tasks = ["t1,5,acct1,payments","t2,3,acct2,payments|risk","t3,4,acct1,payments|risk","t4,2,acct3,risk"]return = ["t1:Alice","t2:Bob","t3:Alice","t4:Bob"]t1 goes to Alice by input-order tie-break. t2 goes to Bob, the lowest-workload eligible worker. For t3, Alice has account affinity and is selected despite a larger workload. t4 requires risk and goes to Bob.
Example 2
workers = ["A,java","B,python"]tasks = ["x,2,c1,ruby","y,1,c1,java|python","z,1,c1,python"]return = ["y:A","z:B"]x is skipped because no worker has ruby. y ties at zero and chooses A. z requires python, so it goes to B; A's account history cannot override the skill requirement.
Constraints
- Worker names are unique and every worker has one specialty.
- Task IDs are unique and durations are non-negative integers.
- Task skill lists are non-empty and use
|as the delimiter. - Workers start with workload 0 and no account history.
- Input order breaks workload ties.
- A task with no eligible worker is skipped.
More Stripe problems
- Group Linked Merchant RecordsPHONE SCREEN Β· Seen Jul 2026
- Invoice / Payment ReconciliationPHONE SCREEN Β· Seen Jul 2026
- Incident MonitorOA Β· Seen Jul 2026
- Merchant Fraud Risk ScoringOA Β· Seen Jul 2026
- WebSocket Load Balancer β Basic Load Balancing (Part 1)OA Β· Seen Jul 2026
- Rule-Driven Transaction Fraud DetectionOA Β· PHONE SCREEN Β· Seen Jul 2026
- Deployment Window SchedulerOA Β· Seen Jul 2026
- Directly Linked UsersOA Β· Seen Jun 2026