275. H 指数 II

说明:

如果 有多有种可能的值 ,h 指数是其中最大的那个。

package leetcode;

public class HindexIISolution {
    public int hIndex(int[] citations) {
        if(citations==null ||citations.length ==0){
            return 0;
        }
        int low = 0 ;
        int high =citations.length;
        int length =citations.length;

        int result =0;

        while(low < high){
            int middle = low + (high-low)/2;
            if(citations[middle] >= length -middle){
                result = length-middle;
                high = middle ;
            }else{
                low = middle+1 ;
            }
        }
        return result ;
    }
    public static void main(String[] args){
        int[] citations ={1,3,5,6,7};
        int index = new HindexIISolution().hIndex(citations);
        System.out.println(index);
    }
}
原文地址:https://www.cnblogs.com/goodtest2018/p/13688629.html