Skip to content

Practice Relative Ranks

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#506
LeetCode Problem

Relative Ranks

Problem Statement

Given distinct athlete scores, return one label per original position. The highest score receives Gold Medal, the second Silver Medal and the third Bronze Medal. Every lower score receives its one-based rank as a decimal string. Ranking is by decreasing score, while the returned labels retain the input order.

Source: Relative Ranks on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
score = [5,4,3,2,1]
Output
["Gold Medal","Silver Medal","Bronze Medal","4","5"]

# Example 2

Input
score = [10,3,8,9,4]
Output
["Gold Medal","5","Bronze Medal","Silver Medal","4"]

Constraints

n == score.length
1 <= n <= 10^4
0 <= score[i] <= 10^6
All the values in score are unique.

Related LeetCode Problems

Practice more problems similar to Relative Ranks.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.