【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
相关推荐
YuTaoShao2 小时前
【LeetCode 每日一题】1277. 统计全为 1 的正方形子矩阵
算法·leetcode·矩阵
古译汉书2 小时前
嵌入式铁头山羊stm32-ADC实现定时器触发的注入序列的单通道转换-Day26
开发语言·数据结构·stm32·单片机·嵌入式硬件·算法
野犬寒鸦2 小时前
力扣hot100:相交链表与反转链表详细思路讲解(160,206)
java·数据结构·后端·算法·leetcode
阿昭L2 小时前
leetcode两数之和
算法·leetcode
周树皮不皮2 小时前
【Leetcode100】算法模板之二叉树
算法
无名客02 小时前
sentinel限流常见的几种算法以及优缺点
算法·sentinel·限流
Lris-KK3 小时前
【Leetcode】高频SQL基础题--1164.指定日期的产品价格
sql·leetcode
Moonbit3 小时前
月报Vol.03: 新增Bitstring pattern支持,构造器模式匹配增强
后端·算法·github
快手技术3 小时前
多模态大模型Keye-VL-1.5发布!视频理解能力更强!
算法
薛定谔的算法3 小时前
JavaScript数组操作完全指南:从基础到高级
前端·javascript·算法