uacs2024

导航

leetcode274. H 指数

274. H 指数

微信截图_20251030200443

自己写的先排序后反向遍历

class Solution {
    public int hIndex(int[] citations) {
        int n = citations.length;
        Arrays.sort(citations);
        if(citations[0] >= n)  return n;
        if(citations[n-1] == 0)  return 0;
        int h = 0;
        for(int i = n - 1;i >= 0;--i){
            if(citations[i] > h)  ++h;
        }
        return h;
    }
}

 

posted on 2025-10-31 14:33  ᶜʸᵃⁿ  阅读(0)  评论(0)    收藏  举报