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.

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

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
Max-Heap
Greedy
Marginal Gain
Floating Point
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
  • 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 Problems
Sample Answer
Requirements
  • Input: list of (passed, total) with 0 < total and passed <= total; integer extra >= 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 ...


Submit Your Answer
Markdown supported