HTMLify
Calculating the H-Index
Views: 1 | Author: prakhardoneria
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | class Solution: def hIndex(self, citations): n = len(citations) buckets = [0] * (n + 1) for c in citations: if c >= n: buckets[n] += 1 else: buckets[c] += 1 count = 0 for i in range(n, -1, -1): count += buckets[i] if count >= i: return i return 0 |