

class Solution:
def hIndex(self, citations: List[int]) -> int:
n = len(citations)
citations = sorted(citations, reverse=True)
h_idx = 0
for i in range(n):
if citations[i] >= i+1:
h_idx += 1
return h_idx
c < i, avoiding unnecessary scanslist.sort() instead of sorted(), reducing extra memory.enumerate(..., start=1) + immediate return minimizes off-by-one risksclass Solution:
def hIndex(self, citations: List[int]) -> int:
citations.sort(reverse=True)
for i, c in enumerate(citations, start=1):
if c < i:
return i - 1
return len(citations)
class Solution:
def hIndex(self, citations: List[int]) -> int:
n = len(citations)
count = [0] * (n + 1)
for c in citations:
count[min(c, n)] += 1
papers = 0
for h in range(n, -1, -1):
papers += count[h]
if papers >= h:
return h
For large-scale data or when optimal time complexity is required, the counting sort approach() is the best choice