【LeetCode 274】H指数

1. 题目

2. 分析

这题没啥难度,需要熟练运用Python API。
sort(reverse=True)可以用于排序List,并且倒序排序。

3. 代码

python 复制代码
class Solution:
    def hIndex(self, citations: List[int]) -> int:
        citations.sort(reverse=True)
        res = 0
        for idx,cite in enumerate(citations):
            if idx+1 > cite:
                break
            res = idx+1
            print(idx,cite)        
        return res
相关推荐
NineData几秒前
第三届数据库编程大赛-八强决赛成绩揭晓
数据库·算法·代码规范
雍凉明月夜15 分钟前
深度学习之目标检测yolo算法Ⅱ(v4)
深度学习·算法·yolo·目标检测
FAFU_kyp1 小时前
Rust 的 引用与借用
开发语言·算法·rust
永远都不秃头的程序员(互关)1 小时前
【K-Means深度探索(一)】数据炼金术第一步:从零手撕K-Means聚类算法
算法·kmeans·聚类
我想回家种地1 小时前
算法期末复习
算法
rgeshfgreh1 小时前
MPPI算法实战:运动规划新利器
算法
Xの哲學1 小时前
Linux epoll 深度剖析: 从设计哲学到底层实现
linux·服务器·网络·算法·边缘计算
小猪咪piggy1 小时前
【leetcode100】回溯
数据结构·算法
m0_603888712 小时前
More Images, More Problems A Controlled Analysis of VLM Failure Modes
人工智能·算法·机器学习·ai·论文速览
恶魔泡泡糖2 小时前
51单片机矩阵按键
c语言·算法·矩阵·51单片机