class Solution: def hIndex(self, citations: List[int]) -> int: citations.sort(reverse=True) h = 0 for index, c in enumerate(citations): if c >= index + 1: h = index + 1 else: break return h class Solution: def hIndex(self, citations: List[int]) -> int: n = len(citations) counts = [0]*(n+1) # buckets the for c in citations: if c>=n: counts[n] += 1 else: counts[c] += 1 total = 0 for i in range(n, -1, -1): total += counts[i] if total >= i: return i return 0