Fewest Reward Credits for Raters Where Higher Scores Beat Neighbors
Last updated: November 29, 2026
Quick Overview
Raters stand in a line, each with a quality score. Every rater gets at least one credit, and any rater with a strictly higher score than an adjacent rater must get more credits than that neighbor. Return the minimum total credits.
0
0
0 solved
Raters stand in a line, each with a quality score. Every rater gets at least one credit, and any rater with a strictly higher score than an adjacent rater must get more credits than that neighbor. Return the minimum total credits.
A Google onsite greedy problem, framed around paying search quality raters with a fairness constraint relative to neighbors in a review queue. The interviewer wants the two-pass solution and a clear argument for why taking the max of the left and right constraints is both feasible and minimal.
What the Interviewer Expects
- States both neighbor constraints separately
- Uses a left-to-right pass for increasing runs
- Uses a right-to-left pass and takes the max
- Explains why the result is minimal
- Mentions the O(1) space slope-counting variant
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
- Solve it in O(1) extra space.
- What if the raters sit in a circle?
- What if equal scores must also receive equal credits?
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
scoresof integers, length n >= 1. - Output: minimum total of
credits[i]withcredits[i] >= 1, andcredits[i] > credits[i-1]wheneverscores[i] > scores[i-1](and similarly for...
High-Level Design
Split the constraints by direction. Left pass: L[i] = L[i-1] + 1 if scores[i] > scores[i-1], else 1. This is the minimum needed to satisfy only left neighbors. Right pass: R[i] = R[i+1] + 1 if `...