【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
相关推荐
鱼跃鹰飞23 分钟前
Leetcode尊享面试100题:1060. 有序数组中的缺失元素
算法·leetcode·面试
啊我不会诶27 分钟前
AtCoder Beginner Contest 438 vp补题
算法
computersciencer27 分钟前
用最小二乘法求解一元一次方程模型的参数
算法·机器学习·最小二乘法
mit6.82436 分钟前
扫描线|离散化|seg+二分|卡常
算法
不穿格子的程序员42 分钟前
从零开始写算法——二叉树篇6:二叉树的右视图 + 二叉树展开为链表
java·算法·链表
大志若愚YYZ1 小时前
ROS2学习 C++中的this指针
c++·学习·算法
AI科技星1 小时前
光子的几何起源与量子本质:一个源于时空本底运动的统一模型
服务器·人工智能·线性代数·算法·机器学习
源代码•宸1 小时前
Golang原理剖析(map面试与分析)
开发语言·后端·算法·面试·职场和发展·golang·map
CodeByV1 小时前
【算法题】栈
算法
sprintzer1 小时前
1.6-1.15力扣数学刷题
算法·leetcode·职场和发展