every blog every motto: You will never know unless you try
0. 前言
生活好难,再坚持坚持!
1. 字符串
1.1 题目
1.2
class Solution:
def findRelativeRanks(self, score: List[int]) -> List[str]:
score_sort = sorted(score, reverse=True)
# 排名
rank = ['Gold Medal', 'Silver Medal', 'Bronze Medal'] + [str(i + 4) for i in range(len(score) - 3)]
# 组成字典
dic = dict(zip(score_sort, rank))
res = [dic.get(i) for i in score]
return res