【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
相关推荐
民乐团扒谱机3 分钟前
【微实验】谱聚类之大规模数据应用——Nyström 方法
人工智能·算法·机器学习·matlab·数据挖掘·聚类·谱聚类
CoderYanger5 分钟前
A.每日一题——3606. 优惠券校验器
java·开发语言·数据结构·算法·leetcode
CoderYanger15 分钟前
D.二分查找-基础——744. 寻找比目标字母大的最小字母
java·开发语言·数据结构·算法·leetcode·职场和发展
元亓亓亓18 分钟前
LeetCode热题100--347. 前 K 个高频元素--中等
数据结构·算法·leetcode
Hello eveybody22 分钟前
冒泡、选择、插入排序简介(C++)
数据结构·算法·排序算法
CoderYanger23 分钟前
贪心算法:2.将数组和减半的最少操作次数
java·算法·leetcode·贪心算法·1024程序员节
Chen--Xing26 分钟前
LeetCode 49.字母异位词分组
c++·python·算法·leetcode·rust
长安er29 分钟前
LeetCode 235 & 236 最近公共祖先(LCA)解题总结
算法·leetcode·二叉树·递归·lca
im_AMBER32 分钟前
Leetcode 77 数组中的最大数对和 | 统计坏数对的数目
笔记·学习·算法·leetcode
代码游侠37 分钟前
学习笔记——Linux 进程管理笔记
linux·运维·笔记·学习·算法