H-Index

https://www.lintcode.com/problem/h-index/description

import java.util.Arrays;

public class Solution {
    /**
     * @param citations: a list of integers
     * @return: return a integer
     */
    public int hIndex(int[] citations) {
        // write your code here
        Arrays.sort(citations);
        int hIndex = 0;
        for (int i = citations.length - 1; i >= 0; i--) {
            int citation = citations[i];
            int count = citations.length - i;
            int min = Math.min(count, citation);
            hIndex = Math.max(min, hIndex);
        }
        return hIndex;
    }
}

你可能感兴趣的:(H-Index)