dsa · easy

Relative Ranks

score holds a distinct score for each athlete, in their original order. Rank them from highest score to lowest:

Arguments

Return a list of those labels in the **original** athlete order.

Example

score = [5, 4, 3, 2, 1] is already decreasing, so the labels are ["Gold Medal", "Silver Medal", "Bronze Medal", "4", "5"].

score = [10, 3, 8, 9, 4]: 10 is first, 9 second, 8 third, 4 fourth, 3 fifth → ["Gold Medal", "5", "Bronze Medal", "Silver Medal", "4"].

Constraints

1 <= score.length <= 4*10^4 0 <= score[i] <= 10^6 All values in score are unique Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
[5, 4, 3, 2, 1]

Expected:
["Gold Medal","Silver Medal","Bronze Medal","4","5"]

Example 2

Input:
[10, 3, 8, 9, 4]

Expected:
["Gold Medal","5","Bronze Medal","Silver Medal","4"]

Open in the Dojo editor