Skill-Aware Task Router With Per-Expert Capacity Limits

Last updated: November 29, 2026

Quick Overview

Build a router that assigns incoming labeling tasks, each tagged with one required skill, to the eligible expert with the fewest active tasks under their capacity. Tasks with no free eligible expert wait, and when an expert completes a task they immediately take the oldest waiting task they are qualified for.

Mercor
Coding & Algorithms
Software Engineer
Mercor
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Build a router that assigns incoming labeling tasks, each tagged with one required skill, to the eligible expert with the fewest active tasks under their capacity. Tasks with no free eligible expert wait, and when an expert completes a task they immediately take the oldest waiting task they are qualified for.

Mercor routes work from AI lab projects to experts with specific domains (law, medicine, finance, code) while keeping load fair and queues short. The onsite coding round checks data structure choice, lazy deletion in heaps, and clean handling of the wait queue.

What the Interviewer Expects
  • Support submit and complete operations with sub-linear selection
  • Use per-skill min-heaps keyed by (load, expert_id) with lazy invalidation
  • Keep waiting tasks FIFO across all of an expert's skills using a global sequence number
  • Break ties deterministically
  • Analyze the cost per operation and memory growth from stale heap entries
Key Topics to Cover
heaps
lazy deletion
queues
load balancing
scheduling
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you add task priority so urgent lab deadlines jump the queue?
  • Experts have quality scores; how would you prefer higher-quality experts without starving others?
  • How would this work across multiple router processes sharing state in Postgres or Redis?
  • How would you bound heap growth from stale entries?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Experts are given as {expert_id: (skills, capacity)}. submit(task_id, skill) returns the assigned expert or None if the task must wait. complete(task_id) frees a slot and returns `(task_id, ex...

High-Level Design
  • load[e] and cap[e] per expert.
  • One min-heap per skill holding (load, expert_id). Whenever an expert's load changes and they still have room, push a fresh entry into each of their skill heaps...

Submit Your Answer
Markdown supported

Related Questions