Question
A review site collects integer scores for a film, one per reviewer, in submission order. The editors call two reviewers a "balanced pair" when their scores add up to exactly target. Given the score list and the target, count the number of unordered reviewer pairs (i, j) with i < j whose scores sum to target. Every index pair counts even when the values are equal. For example, scores [3, 7, 5, 5, 7] with target 10 contain three balanced pairs: the 3 with each 7, and the two 5s together. Aim for a single pass.
rating_pairs(ratings: list[int], target: int) → int[[3,7,5,5,7],10]out3State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.