边工作边刷题:70天一遍leetcode: day 57

H-Index I/II

要点:

class Solution(object):
    def hIndex(self, citations):
        """
        :type citations: List[int]
        :rtype: int
        """
        if not citations: return 0
        n = len(citations)
        low,high=0, n-1
        mid = low + (high-low)/2
        while low < high:
            if citations[mid]>=n-mid:
                high = mid
            else:
                low = mid+1
            mid = low + (high-low)/2
            
        return n-mid if citations[mid]>=n-mid else 0 

原文地址:https://www.cnblogs.com/absolute/p/5690324.html