Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 551 Bytes

File metadata and controls

32 lines (22 loc) · 551 Bytes

H-Index

Description

link


Solution

Find the first item who's index more than value in sorted citations


Code 1

Complexity T : O(nlog(n)) M : O(n)

class Solution:
    def hIndex(self, citations):
        """
        :type citations: List[int]
        :rtype: int
        """
        citations = sorted(citations,reverse = True) + [0]

        for i, val in enumerate(citations):
            if i >= val:
                return i
        return 0