Hire K Search Quality Raters at Minimum Cost With Proportional Pay

Last updated: November 29, 2026

Quick Overview

Each rater has a quality score and a minimum wage. Hire exactly k raters so each is paid at least their minimum and pay within the group is proportional to quality. Return the minimum total payroll.

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

0

0

0 solved


Each rater has a quality score and a minimum wage. Hire exactly k raters so each is paid at least their minimum and pay within the group is proportional to quality. Return the minimum total payroll.

A Google onsite hard greedy question in a search quality rater staffing frame. The interviewer wants the observation that the group's pay rate is set by its highest wage-to-quality ratio, then a max-heap of qualities to keep the cheapest k.

What the Interviewer Expects
  • Derives that pay rate = max(wage / quality) in the group
  • Sorts raters by that ratio ascending
  • Keeps the k smallest qualities in a max-heap
  • Computes cost = ratio * sum of qualities
  • States O(n log n)
Key Topics to Cover
Max-Heap
Greedy
Sorting
Ratios
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
  • Prove why the captain (max ratio) must be in the group
  • What if you can hire between a and b raters?
  • How would floating point affect the answer?
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: lists quality and wage of length n, integer k.
  • Pay is rate * quality[i] for one shared rate, and must be >= wage[i] for each hired rater.
  • Output: minimum total pay for exactly k r...
High-Level Design

With proportional pay, a group is paid rate * sum(quality), and the rate must satisfy rate >= wage[i] / quality[i] for every member, so the cheapest valid rate is the maximum ratio in the group. C...


Submit Your Answer
Markdown supported