straightforward O(n) python solution (need help to make code cleaner!)


  • 0
    S
        def hIndex(self, citations):
            l = len(citations)
            listt = [0] * (l+1)
            for paper in citations:
                if paper > l:
                    listt[l] += 1
                else:
                    listt[paper] += 1
            sum = 0
            k = l
            while sum <= k:
                sum += listt[k]
                k -= 1
            return k+1
    

Log in to reply
 

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