My easy Python solution. O(1) space and O(NlogN) time

  • 0
    def hIndex(self, cit):
        h, cit = 0, sorted(cit, reverse=True)
        for i, v in enumerate(cit):
            if v > i:
                h = i + 1
        return h

Log in to reply

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