Balanced Human, Model and Task Assignment
Updated
Problem statement
A labeling team rates answers written by AI models. There are humans raters, numbered from 0, and models AI models, also numbered from 0. There are ratings.length tasks, numbered from 0, and task t needs ratings[t] ratings.
One rating means one human reads one model's answer to one task. We write it as a triple [task, human, model].
The goal is to spread the work evenly over three kinds of pairs: human with model, human with task, and model with task. Build the triples with this greedy rule:
- Go through the tasks in order
0, 1, 2, .... For each taskt, make itsratings[t]ratings one at a time. - For the next rating of task
t, give every pair of a humanhand a modelma score. The score adds three counts over the ratings made so far: how many usedhtogether withm(on any task), how many were ratings of tasktbyh, and how many were ratings of tasktthat usedm. - Choose the pair with the smallest score. If several pairs tie, choose the one whose human has made the fewest ratings so far (on all tasks). If that still ties, choose the one whose model has been used in the fewest ratings so far. If that still ties, choose the smaller human number, and then the smaller model number.
- Record the triple
[t, h, m]and update the counts before making the next rating.
Return every triple in the order it was made. A task may need more ratings than there are humans or models; then some human or model is used on that task more than once.
Function
assignRatings(humans: int, models: int, ratings: int[]) → int[][]Examples
Example 1
humans = 2models = 2ratings = [2,2]return = [[0,0,0],[0,1,1],[1,0,1],[1,1,0]]Task 0, first rating: nothing has been used yet, so every pair scores 0 and has load 0. The smallest indexes win: human 0 with model 0.
Task 0, second rating: human 1 with model 1 scores 0, because neither of them has been paired with each other or used on task 0. Every other pair scores at least 1.
Task 1, first rating: human 0 with model 1 and human 1 with model 0 both score 0, and all loads are 1, so the smaller human index wins: human 0 with model 1. Task 1, second rating: human 1 with model 0 scores 0. In the end, every human worked with every model exactly once.
Example 2
humans = 3models = 2ratings = [1,1,1,1]return = [[0,0,0],[1,1,1],[2,2,0],[3,0,1]]Each task needs one rating, so the task-human and task-model counts never matter here. Only the human-model counts and the loads do.
Task 0 takes human 0 with model 0. For task 1, every pair except (0, 0) scores 0. Humans 1 and 2 both have load 0, and model 1 has load 0 while model 0 has load 1. So (1, 1) and (2, 1) are equal on score, human load and model load, and the smaller human number makes (1, 1) win.
For task 2, human 2 has load 0, and both of its pairs score 0 and use a model with load 1, so the smaller model index wins: (2, 0). For task 3, every human has load 1. (0, 1) and (2, 1) score 0 and use model 1 with load 1, while (1, 0) uses model 0 with load 2. The smaller human index wins: (0, 1).
Example 3
humans = 2models = 3ratings = [3,1]return = [[0,0,0],[0,1,1],[0,0,2],[1,1,0]]Task 0 needs 3 ratings, but there are only 2 humans, so one human must rate it twice.
First rating: (0, 0). Second rating: (1, 1) and (1, 2) score 0; both use human 1 and an unused model, so model 1 wins by index. Third rating: model 2 is still new to task 0, so (0, 2) and (1, 2) both score 1 (each human already rated task 0 once). Both humans have load 1 and model 2 has load 0, so human 0 wins by index.
Task 1, one rating: (1, 0) and (1, 2) score 0, while human 0 now has load 2. Both models have load 1, so model 0 wins by index.
Constraints
1 <= humans, models <= 251 <= ratings.length <= 5001 <= ratings[t] <= 10- The sum of all
ratings[t]is at most1000.
More OpenAI Phone Screen questions
- Secret Number Search with One-Call-Delayed FeedbackPHONE SCREEN · Seen Nov 2026
- Determine the Winner of Three-Card HandsPHONE SCREEN · Seen Nov 2026
- Grid Infection with Recovery After D DaysPHONE SCREEN · Seen Nov 2026
- Sparse Plant Infection SimulationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Light Source Hits: Sample, Compare, and FitPHONE SCREEN · Seen Nov 2026
- Rectangle Point Coverage CountsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Adaptive Calibration ErrorPHONE SCREEN · Seen Nov 2026
- Elevator Scheduling SimulationPHONE SCREEN · Seen Nov 2026
- Evaluate Noisy AnnotatorsPHONE SCREEN · Seen Oct 2026
- Network Endpoint or Cycle BoundaryOA · PHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Explore an Unknown Grid and Find a PathLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
- Flipping MatrixZomato / Eternal · ONSITE INTERVIEWZomato / Eternal interview questions
- Spiral MatrixNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions
- Days Until Poisoned Plants StabilizeApple · PHONE SCREENApple interview questions
- Apply a 2048 Board MoveGlean · PHONE SCREENGlean interview questions
- Dense Matrix MultiplicationAmazon · PHONE SCREEN
- File-Backed Dense Game of LifeApplied Intuition · PHONE SCREENApplied Intuition interview questions
- Tic-Tac-Toe Move WinnersByteDance · ONSITE INTERVIEWByteDance interview questions
- Tilting Maze BallHudson River Trading · PHONE SCREENHudson River Trading interview questions
- Spiral Order with ObstaclesTemu · PHONE SCREENTemu interview questions