【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
相关推荐
a伊雪3 分钟前
c++ 引用参数
c++·算法
圣保罗的大教堂33 分钟前
leetcode 3531. 统计被覆盖的建筑 中等
leetcode
Data_agent1 小时前
1688获得1688店铺列表API,python请求示例
开发语言·python·算法
2301_764441331 小时前
使用python构建的应急物资代储博弈模型
开发语言·python·算法
hetao17338372 小时前
2025-12-11 hetao1733837的刷题笔记
c++·笔记·算法
Xの哲學2 小时前
Linux电源管理深度剖析
linux·服务器·算法·架构·边缘计算
小飞Coding2 小时前
一文讲透 TF-IDF:如何用一个向量“代表”一篇文章?
算法
算家计算2 小时前
突然发布!GPT-5.2深夜来袭,3个版本碾压人类专家,打工人该怎么选?
算法·openai·ai编程
s09071363 小时前
Xilinx FPGA 中ADC 数据下变频+ CIC 滤波
算法·fpga开发·fpga·zynq
TL滕4 小时前
从0开始学算法——第十二天(KMP算法练习)
笔记·学习·算法