【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
相关推荐
hanlin037 小时前
刷题笔记:力扣第32题-最长有效括号
笔记·算法·leetcode
All for pursuit.7 小时前
【动态规划-21】312.戳气球
数据结构·c++·算法·leetcode·动态规划
碧海银沙音频科技研究院10 小时前
基于炬芯ATS3089X自研AEC声学回声消除算法
算法
通问AI10 小时前
在两台 Mac Studio 上跑 800B 模型:MLX + RDMA over Thunderbolt 实测与四道门选型法
算法
ZywOo62310 小时前
《算法竞赛进阶指南》0x03 前缀和与差分
算法
Scintilla_y10 小时前
DAY2 滑动窗口
算法·leetcode·散列表
lvwangshu10 小时前
笛卡尔树
算法·图论
026d2310 小时前
状态信号只知“其然”不知“其所以然”:变工况机械故障诊断的物理盲区
算法
姜鱼问生11 小时前
备份和服务器在同一台机器上,等于没备份
算法·架构
姜鱼问生11 小时前
别再 chmod 777 了,用 ACL 给它开一扇窗
后端·算法·架构