# 274. H-Index

Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.

According to the definition of h-index on Wikipedia: "A scientist has index h if h of his/her N papers have at least h citations each, and the other N − h papers have no more than h citations each."

For example, given citations = [3, 0, 6, 1, 5], which means the researcher has 5 papers in total and each of them had received 3, 0, 6, 1, 5 citations respectively. Since the researcher has 3 papers withat least 3 citations each and the remaining two with no more than 3 citations each, his h-index is 3.

Note: If there are several possible values for h, the maximum one is taken as the h-index.

public class Solution {
public int hIndex(int[] citations) {
int length = citations.length;
if(length==0){
return 0;
}

int[] index = new int[length+1];
for(int i=0; i<length; i++){ //将引用次数作为下标，对相同引用次数的计数。
if(citations[i]>length){
index[length] += 1;
}else{
index[citations[i]] += 1;
}
}

int count = 0;
for(int i=length; i>=0; i--){
count = count + index[i]; //统计大于序号的文章数
if(count>=i){ //如果文章数大于排序序号时，返回H值
return i;
}
}
return 0;
}
}


public class Solution {
public int hIndex(int[] citations) {

Arrays.sort(citations);
int len = citations.length;
if(len==0){
return 0;
}

for(int i=0; i<len; i++){
if(citations[i]>=len-i){
return len-i;
}
}
return 0;
}
}


• 本文已收录于以下专栏：

## 274. H-Index

//8ms merge class Solution { public: void merge(vector& v,int l,int m,int r) { int s...

## leetcode274~H-Index

Given an array of citations (each citation is a non-negative integer) of a researcher, write a funct...

## <LeetCode OJ> 274 / 275 H-Index(I / II)

Total Accepted: 37719 Total Submissions: 125936 Difficulty: Medium Given an array of citations ...

## leetcode_middle_87_274. H-Index

• pusude
• 2017年03月09日 15:15
• 142

## LeetCode 274. H-Index（文献）

• jmspan
• 2016年04月13日 10:58
• 348

## Leetcode 274. H-Index & 275. H-Index II

274. H-Index Total Accepted: 49757 Total Submissions: 159122 Difficulty: Medium Given an a...

## OMX_TI_Index.h

• 2014年12月22日 22:50
• 17KB
• 下载

## leetcode笔记：H-Index

举报原因： 您举报文章：274. H-Index 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)