Skip to content
← Back to the archive

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 entries
  • each score is a whole number between -10000 and 10000
  • target is a whole number between -20000 and 20000
  • a position can only pair with a later position, never with itself

Function signature

def count_pair_sum_matches(scores, target):

Sign in to solve this bracket

Reading the problem is free for everyone. Opening the editor and solving it requires an account with Open Bracket+.