【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
相关推荐
RTC老炮8 小时前
webrtc降噪-PriorSignalModelEstimator类源码分析与算法原理
算法·webrtc
草莓火锅10 小时前
用c++使输入的数字各个位上数字反转得到一个新数
开发语言·c++·算法
散峰而望10 小时前
C/C++输入输出初级(一) (算法竞赛)
c语言·开发语言·c++·算法·github
Kuo-Teng11 小时前
LeetCode 160: Intersection of Two Linked Lists
java·算法·leetcode·职场和发展
fie888911 小时前
基于MATLAB的狼群算法实现
开发语言·算法·matlab
偷偷的卷11 小时前
【算法笔记 11】贪心策略六
笔记·算法
ZPC821012 小时前
FPGA 部署ONNX
人工智能·python·算法·机器人
_w_z_j_12 小时前
爱丽丝的人偶
算法
老前端的功夫13 小时前
Vue2中key的深度解析:Diff算法的性能优化之道
前端·javascript·vue.js·算法·性能优化
yongui4783413 小时前
基于深度随机森林(Deep Forest)的分类算法实现
算法·随机森林·分类