(OpenAI)
Your goal is to generate an allocation schedule that is strictly prefix-balanced.
A schedule is prefix-balanced if it satisfies both conditions:
Task-Model Balance: For each task, the number of times it is assigned to each model must differ by at most 1 (including models with 0 uses). Formally: max_count(task, model) - min_count(task, model) <= 1. Balanced example: task "t1" uses "m1" twice and "m2" once (difference is 1). Not-balanced example: task "t1" uses "m1" three times and "m2" zero times (difference is 3).
Human-Model Balance: For each human annotator, the usage count across all models must differ by at most 1 (including models with 0 uses). Formally: max_count(human, model) - min_count(human, model) <= 1. Balanced example: human "h1" uses "m1" once and "m2" once (difference is 0). Not-balanced example: human "h1" uses "m1" twice and "m2" zero times (difference is 2).
Now write a function to return any valid prefix-balanced reindexing cycle. If no such schedule exists, return an empty list.
Your goal is to generate an allocation schedule that is strictly prefix-balanced.
A schedule is prefix-balanced if it satisfies both conditions:
Task-Model Balance: For each task, the number of times it is assigned to each model must differ by at most 1 (including models with 0 uses). Formally: max_count(task, model) - min_count(task, model) <= 1. Balanced example: task "t1" uses "m1" twice and "m2" once (difference is 1). Not-balanced example: task "t1" uses "m1" three times and "m2" zero times (difference is 3).
Human-Model Balance: For each human annotator, the usage count across all models must differ by at most 1 (including models with 0 uses). Formally: max_count(human, model) - min_count(human, model) <= 1. Balanced example: human "h1" uses "m1" once and "m2" once (difference is 0). Not-balanced example: human "h1" uses "m1" twice and "m2" zero times (difference is 2).
Now write a function to return any valid prefix-balanced reindexing cycle. If no such schedule exists, return an empty list.
Get one-to-one training from Google Facebook engineers
Top-notch Professionals
Learn from Facebook and Google senior engineers interviewed 100+ candidates.
Most recent interview questions and system design topics gathered from aonecode alumnus.
One-to-one online classes. Get feedbacks from real interviewers.
Customized Private Class
Already a coding expert? - Advance straight to hard interview topics of your interest.
New to the ground? - Develop basic coding skills with your own designated mentor.
Days before interview? - Focus on most important problems in target company question bank.