Assign Extra Reviewers to Maximize Average Pass Rate Across Teams
Last updated: November 29, 2026
Quick Overview
Each team has (passed, total) code reviews. You may add extra guaranteed-pass reviews, each going to one team as +1 passed and +1 total. Distribute them to maximize the average of the teams' pass ratios.
0
0
0 solved
Each team has (passed, total) code reviews. You may add extra guaranteed-pass reviews, each going to one team as +1 passed and +1 total. Distribute them to maximize the average of the teams' pass ratios.
A Google onsite greedy question in an engineering productivity metrics frame. The interviewer wants the marginal-gain insight and a max-heap keyed on how much one more pass would raise a team's ratio.
What the Interviewer Expects
- Computes marginal gain (p+1)/(t+1) - p/t
- Uses a max-heap on marginal gain
- Recomputes gain after each assignment
- Explains diminishing returns that make greedy optimal
- Returns the average as a float
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Why is the greedy optimal here?
- What if extras could also fail with some probability?
- What if each team has a cap on extras?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input: list of
(passed, total)with0 < totalandpassed <= total; integerextra >= 0. - Each extra adds 1 to both passed and total of one team.
- Output: maximum achievable average ratio....
High-Level Design
The objective is a sum of per-team ratios, so the best use of a single extra is the team whose ratio rises the most: gain = (p + 1)/(t + 1) - p/t = (t - p)/(t(t + 1)). That gain strictly decreases as ...