H-Index

public class Solution {
    public int hIndex(int[] citations) {
        int length = citations.length;
        int[] record = new int[length + 1];
        for (int i = 0; i < length; i++) {
            if (citations[i] >= length) {
                record[length] ++;
            } else {
                record[citations[i]] ++;
            }
        }
        int count = 0;
        for (int i = length; i >= 0; i--) {
            count += record[i];
            if (count >= i) {
                return i;
            }
        }
        return 0;
    }
}

 

posted @ 2015-11-26 07:52  Weizheng_Love_Coding  阅读(117)  评论(0)    收藏  举报