My easy python solution


  • 0
    Y

    In short, I suppose the possible value of h from 1 to n, the total number of the paper list. In the inner for loop, go through all the index and count the paper which has the larger citation number than h. After all, report the max h which meet the requirement.

        def hIndex(self, citations):
            """
            :type citations: List[int]
            :rtype: int
            """
            n=len(citations)
            result=0
            citations.sort()
            for h in range(1,n+1):
                count=0
                for i in range(n):
                    if citations[i]>=h:
                        count+=1
                if count>=h:
                    result=max(h,result)
            return result
    

Log in to reply
 

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