36 ms H-Index simple python implementation


  • 1
    V
    class Solution(object):
        def hIndex(self, citations):
            """
            :type citations: List[int]
            :rtype: int
            """
            l = len(citations)
            count = [0]* (l+1)
            
            for c in citations:
                if c >= l:
                    count[l] +=1
                else:
                    count[c] +=1
            t = 0
            for i in xrange(l, -1, -1):
                t = t + count[i]
                if t >= i:
                    return i
            
            return 0

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.