【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
相关推荐
wanderist.2 小时前
2025年蓝桥杯省赛C++大学A组
c++·算法·蓝桥杯
啊董dong2 小时前
noi-2025年12月16号作业
数据结构·c++·算法·noi
white-persist2 小时前
【攻防世界】reverse | simple-check-100 详细题解 WP
c语言·开发语言·汇编·数据结构·c++·python·算法
长安er3 小时前
LeetCode 01 背包 & 完全背包 题型总结
数据结构·算法·leetcode·动态规划·背包问题
小南家的青蛙3 小时前
LeetCode第2658题 - 网格图中鱼的最大数目
算法·leetcode·职场和发展
ZHang......3 小时前
LeetCode 1114. 按序打印
java·开发语言·算法
仰泳的熊猫3 小时前
1083 List Grades
数据结构·c++·算法·pat考试
Tan_Zhixia3 小时前
时间复杂度判断
数据结构·c++·算法
雪弯了眉梢4 小时前
OpenGL(八)摄像机(Camera)
算法·图形渲染·opengl
~~李木子~~4 小时前
基于 MovieLens-100K 数据集的推荐算法设计与实现
算法·机器学习·推荐算法