码迷,mamicode.com
首页 > 其他好文 > 详细

H-Index

时间:2015-11-26 08:11:05      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:

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;
    }
}

 

H-Index

标签:

原文地址:http://www.cnblogs.com/vision-love-programming/p/4996527.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!