274. H 指数

 

 

package leetcode;

import java.util.Arrays;

public class HindexSolution {
    public int hIndex(int[] citations) {
        Arrays.sort(citations);
        for(int i =0 ; i < citations.length ; i++){
            if(citations[i] >=citations.length-i){
                return  citations.length - i ;
            }
        }
        return 0;
    }
    public static void main(String[] args){
        int[] citations = {3,0,1,5,4,4} ;
        int hi = new HindexSolution().hIndex(citations);
        System.out.println(hi);
    }
}

 

posted on 2020-09-17 00:48  凌晨三点半的飞机  阅读(152)  评论(0编辑  收藏  举报