Created
October 23, 2017 19:45
-
-
Save cixuuz/f6b3d661deebe671a84eee67853323c7 to your computer and use it in GitHub Desktop.
[274. H-Index] #leetcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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