【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
相关推荐
Miraitowa_cheems2 小时前
LeetCode算法日记 - Day 73: 最小路径和、地下城游戏
数据结构·算法·leetcode·职场和发展·深度优先·动态规划·推荐算法
野蛮人6号2 小时前
力扣热题100道之560和位K的子数组
数据结构·算法·leetcode
Swift社区3 小时前
LeetCode 400 - 第 N 位数字
算法·leetcode·职场和发展
fengfuyao9853 小时前
BCH码编译码仿真与误码率性能分析
算法
小白不想白a4 小时前
每日手撕算法--哈希映射/链表存储数求和
数据结构·算法
剪一朵云爱着4 小时前
力扣2080. 区间内查询数字的频率
算法·leetcode
落日漫游4 小时前
数据结构笔试核心考点
java·开发语言·算法
Dream it possible!4 小时前
LeetCode 面试经典 150_栈_有效的括号(52_20_C++_简单)(栈+哈希表)
c++·leetcode·面试··哈希表
workflower5 小时前
Fundamentals of Architectural Styles and patterns
开发语言·算法·django·bug·结对编程
仰泳的熊猫5 小时前
LeetCode:701. 二叉搜索树中的插入操作
数据结构·c++·算法·leetcode