diff --git a/0274-h-index/0274-h-index.py b/0274-h-index/0274-h-index.py new file mode 100644 index 0000000..17f9087 --- /dev/null +++ b/0274-h-index/0274-h-index.py @@ -0,0 +1,13 @@ +class Solution: + def hIndex(self, citations: List[int]) -> int: + citations.sort(reverse=True) + + n = len(citations) + maxSoFar = 0 + for i, x in enumerate(citations): + if i + 1 >= x: + maxSoFar = max(maxSoFar, x) + else: + maxSoFar = max(maxSoFar, i + 1) + + return maxSoFar \ No newline at end of file