Skip to content

Instantly share code, notes, and snippets.

@cixuuz
Created October 23, 2017 19:45
Show Gist options
  • Save cixuuz/f6b3d661deebe671a84eee67853323c7 to your computer and use it in GitHub Desktop.
Save cixuuz/f6b3d661deebe671a84eee67853323c7 to your computer and use it in GitHub Desktop.
[274. H-Index] #leetcode
class Solution(object):
def hIndex(self, citations):
"""
:type citations: List[int]
:rtype: int
"""
# sorting the citations in ascending order
citations = sorted(citations)
# finding h-index by linear search
i = 0
while i < len(citations) and citations[len(citations) - 1 - i] > i:
i += 1
return i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment