11 September 2026
Matching Pair Sums
Hard
Lists
Numbers
Count how many pairs of scores in a list add up to a target value.
You are given a list of trivia scores in the order players answered, and a target sum. Look at every pair of positions in the list where the first position comes before the second. Count a pair every time the two scores at those positions add up to exactly the target. Return the total number of matching pairs. A single score can be part of many different pairs, and repeated values can each be counted separately.
Constraints
scores has between 0 and 300 entrieseach score is a whole number between -10000 and 10000target is a whole number between -20000 and 20000a position can only pair with a later position, never with itself
Function signature
def count_pair_sum_matches(scores, target):