Relative Ranks

Given the scores of athletes, return their ranks, with the top three receiving medal labels. Because the number of ranks is bounded by the array size, sorting by score and assigning labels is straightforward.

Input Format

score = array of distinct athlete scores

Output Format

array of rank strings

Constraints

  • 1 <= score.length <= 10^4; 0 <= score[i] <= 10^6; all scores are distinct

Examples

Example 1:

Input:

score = [5,4,3,2,1]

Output:

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

Explanation:

Scores are ranked from highest to lowest.

Example 2:

Input:

score = [10,3,8,9,4]

Output:

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

Explanation:

Ranks are assigned after sorting by score.

Loading...
Relative Ranks - Sorting Based Array Problems