Time: 0 ms (100%), Space: 16.9 MB (26.86%) - LeetHub

This commit is contained in:
Deven
2024-10-21 09:08:45 -04:00
parent 7003108384
commit 51f4f6e2d3
+13
View File
@@ -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