Problem statement

https://binarysearch.com/problems/H-Index/

Solution

Equal to Leetcode 0274. H-Index.

Complexity

Code

class Solution:
    def solve(self, citations):
        N = len(citations)
        dp = [0] * (N + 1)
        
        for elem in citations:
            dp[min(elem, N)] += 1
        
        accum = list(accumulate(dp[1:][::-1]))[::-1]  
        compar = [accum[i] >= i + 1 for i in range(N)]  
        return (compar + [0]).index(0)