# Middle-题目42/43：274. H-Index && 275. H-Index II

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 with at least 3 citations each and the remaining two with no more than 3 citations each, his h-index is 3.

275.HIndexII$275. H-Index II$

Follow up for H-Index: What if the citations array is sorted in ascending order? Could you optimize your algorithm?

274.HIndex$274. H-Index$

H指数的定义：一个人的h指数是指在一定期间内他发表的论文至少有h篇的被引频次不低于h次。

275.HIndexII$275. H-Index II$

public class Solution {
public int hIndex(int[] citations) {
int count=0,length = citations.length;
int start=0,end=length-1,mid=0;
while(start<=end) {
mid = (start+end) / 2;
if(citations[mid] >= length-mid) {
if(mid==0 || citations[mid-1]<length-mid+1)
return length-mid;
else if(citations[mid-1]>=length-mid)
end=mid-1;
}
else
start=mid+1;
}
return 0;
}
}

H-Index:4ms,beats 9.28%,众数1ms,38.82%
H-Index II:13ms,beats 31.68%,众数12ms,24.72%
Cmershen的碎碎念：

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

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

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

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

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

## 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...

## 274. H-Index

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

## 【LeetCode从零单刷】H-index I & II

举报原因： 您举报文章：深度学习：神经网络中的前向传播和反向传播算法推导 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)