您得到一个n的整数数组分数,其中分数[i]是比赛中的第一个运动员的分数.所有分数都保证是独一无二的.运动员根据他们的分数被排名,其中第一名运动员得分最高,第二名运动员得分最高等等.每个运动员的排名决定他们的排名: - 第一个名的运动员的排名是"金牌". - 第二名运动员的排名是"银牌". - 第三名运动员的排名是"铜牌". - 第四名运动员的排名是他们的排名数 (即第十名运动员的"x"). 返回是答案的数组,其中答案n[i]是第九名运动员的答案.
You can start by creating an empty dictionary to store each athlete's score as the key and their rank as the value. Then, sort the given array in descending order and iterate through it. For the first 3 athletes, assign their respective medals as their rank. For the rest of the athletes, use their placement number as their rank. Finally, populate the answer array with each athlete's rank using the dictionary. Here's the code:

```
def findRanks(score):
    rank_dict = {}
    for i in range(len(score)):
        rank_dict[score[i]] = 0
        
    sorted_scores = sorted(score, reverse=True)
    
    for i in range(len(sorted_scores)):
        if i == 0:
            rank_dict[sorted_scores[i]] = "Gold Medal"
        elif i == 1:
            rank_dict[sorted_scores[i]] = "Silver Medal"
        elif i == 2:
            rank_dict[sorted_scores[i]] = "Bronze Medal"
        else:
            rank_dict[sorted_scores[i]] = str(i+1)
            
    answer = []
    for i in range(len(score)):
        answer.append(rank_dict[score[i]])
        
    return answer
```

You can then call `findRanks` with an array of scores, like this:

```
scores = [10, 5, 15, 20, 25]
ranks = findRanks(scores)
print(ranks) # outputs ["Silver Medal", "5", "Bronze Medal", "Gold Medal", "1"]
```