Assign medals and placement strings to athletes based on their scores.
You are given an array of athlete scores where each score is unique. Rank the athletes from highest score to lowest score and return a new array of the same length containing their relative ranks.
The top three athletes should receive special labels:
Gold Medal for 1st placeSilver Medal for 2nd placeBronze Medal for 3rd placeAll remaining athletes should receive their rank number as a string, starting from 4.
Your task is to produce the rank label for each athlete in the original order of the input array.
score where score[i] is the score of the -th athlete.answer where answer[i] is the rank label for the -th athlete in the original order.score are distinct.Example 1
Input
score = [5,4,3,2,1]
Output
["Gold Medal","Silver Medal","Bronze Medal","4","5"]
Explanation
After sorting by score descending, the ranks are 5, 4, 3, 2, 1. The top three get medal labels, and the rest get their numerical rank as strings.
Example 2
Input
score = [10,3,8,9,4]
Output
["Gold Medal","5","Bronze Medal","Silver Medal","4"]
Explanation
Sorted descending, the scores rank as 10, 9, 8, 4, 3. We then place the corresponding labels back into the original order.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.