LeetCode题解(0275):H指数II(Python)

题目:原题链接(中等)

标签:二分查找、数组

解法时间复杂度空间复杂度执行用时
Ans 1 (Python) O ( l o g N ) O(logN) O(logN) O ( 1 ) O(1) O(1)40ms (85.20%)
Ans 2 (Python)
Ans 3 (Python)

解法一:

class Solution:
    def hIndex(self, citations: List[int]) -> int:
        if not citations:
            return 0

        left, right = 0, len(citations)
        while left < right:
            mid = (left + right + 1) // 2
            if citations[-mid] < mid:
                right = mid - 1
            else:
                left = mid
        return left
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 游动-白 设计师:白松林 返回首页