【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 分钟前
LeetCode-88-合并两个有序数组
java·开发语言·数据结构·python·算法·leetcode·rust
源代码•宸11 分钟前
Leetcode—712. 两个字符串的最小ASCII删除和【中等】
开发语言·后端·算法·leetcode·职场和发展·golang·dp
无限进步_14 分钟前
【C语言&数据结构】相同的树:深入理解二叉树的结构与值比较
c语言·开发语言·数据结构·c++·算法·github·visual studio
java修仙传26 分钟前
力扣hot100:每日温度
算法·leetcode·职场和发展
咚咚王者28 分钟前
人工智能之核心基础 机器学习 第十章 降维算法
人工智能·算法·机器学习
源代码•宸37 分钟前
Golang语法进阶(Context)
开发语言·后端·算法·golang·context·withvalue·withcancel
源代码•宸38 分钟前
Golang语法进阶(Sync、Select)
开发语言·经验分享·后端·算法·golang·select·pool
sali-tec38 分钟前
C# 基于OpenCv的视觉工作流-章8-形态学
人工智能·深度学习·opencv·算法·计算机视觉
栈与堆42 分钟前
数据结构篇(1) - 5000字细嗦什么是数组!!!
java·开发语言·数据结构·python·算法·leetcode·柔性数组
LightYoungLee1 小时前
算法(五)树 Trees V2
学习·算法·深度优先