Python | Leetcode Python题解之第506题相对名次

题目:

题解:

python 复制代码
class Solution:
    desc = ("Gold Medal", "Silver Medal", "Bronze Medal")

    def findRelativeRanks(self, score: List[int]) -> List[str]:
        ans = [""] * len(score)
        arr = sorted(enumerate(score), key=lambda x: -x[1])
        for i, (idx, _) in enumerate(arr):
            ans[idx] = self.desc[i] if i < 3 else str(i + 1)
        return ans
相关推荐
AnalogElectronic5 分钟前
windows文件加解密工具,python实现,速度极快,篡改文件头尾信息以及还原
开发语言·windows·python
m0_5281744511 分钟前
使用Python处理计算机图形学(PIL/Pillow)
jvm·数据库·python
x_xbx21 分钟前
LeetCode:88. 合并两个有序数组
算法·leetcode·职场和发展
ฅ^•ﻌ•^ฅ129 分钟前
LeetCode hot 100(复习c++) 1-15
c++·算法·leetcode
漏刻有时31 分钟前
宝塔面板实现按年月自动备份目录至阿里云 OSS(python脚本、大文件分片上传版)
python·阿里云·云计算
alphaTao31 分钟前
LeetCode 每日一题 2026/3/9-2026/3/15
算法·leetcode·职场和发展
用户03321266636733 分钟前
使用 Python 查找并替换 PDF 中的文本
python
Kiyra34 分钟前
[特殊字符] LeetCode 做题笔记(二):678. 有效的括号字符串
笔记·算法·leetcode
TracyCoder12335 分钟前
LeetCode Hot100(71/100)——152. 乘积最大子数组
算法·leetcode·职场和发展
2201_7562063436 分钟前
1111111
开发语言·python