Problem 335128 · easy · Phase 03 Linear Management & Searching

Medal Table with Ties

sorting · ranking · dictionaries

Given a list of integer scores, return a list of strings of the same length where position i describes the rank of scores[i]:

  • The rank of a score is 1 + (number of scores strictly greater than it), so equal scores share a rank and the next rank is skipped (standard competition ranking: 1, 1, 3).
  • Rank 1 is "Gold Medal", rank 2 is "Silver Medal", rank 3 is "Bronze Medal", and any other rank is its number as a string, e.g. "4".

Examples

Input:  scores = [10, 3, 8, 8, 5]
Output: ["Gold Medal", "5", "Silver Medal", "Silver Medal", "4"]
Explanation: Both 8s are rank 2, so 5 is rank 4 and 3 is rank 5.

Constraints

  • 0 <= len(scores) <= 10**5
  • -10**9 <= scores[i] <= 10**9
  • Target complexity: O(n log n).

Goals

  • Derive ranks from a sorted copy without losing the original positions
  • Apply standard competition ranking (1, 1, 3) for ties
  • Map ranks to labels with a lookup
Starting Python…