H-Index LeetCode solution in Python
1class Solution:2def hIndex(self, citations: List[int]) -> int:3num = sorted(citations)4h = 05j = len(num) - 16for i in range(len(num)):7if i + 1 <= num[i] and j - i + 1 >= num[i]:8h = max(num[i], h)9elif i + 1 <= num[i] and j - i + 1 < num[i]:10h = max(h, j - i + 1)11elif i + 1 > num[i] and j - i + 1 >= num[i]:12h = max(h, num[i])1314return h