Skip to content
← Back to the archive

12 September 2026

Second Highest Distinct Score

Medium Lists Numbers

Find the second highest score in a list once duplicate values are collapsed.

You are given a list of scores from a leaderboard, which may include repeated values. Collapse the list down to its distinct values, ignoring how many times each one appeared. Return the second-highest value among those distinct scores. If there are fewer than two distinct scores in the list, return -1 instead.

Constraints

  • scores has between 0 and 1000 entries
  • each score is a whole number between -1000000 and 1000000

Function signature

def second_highest_score(scores):

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+.