Open Tcdian opened 3 years ago
/**
* @param {number[]} citations
* @return {number}
*/
var hIndex = function(citations) {
citations.sort((a, b) => a - b);
let left = 0;
let right = citations.length - 1;
while (left <= right) {
const mid = (left + right) >> 1;
if (citations[mid] < citations.length - mid) {
left = mid + 1;
} else {
right = mid - 1;
}
}
return citations.length - left;
};
function hIndex(citations: number[]): number {
citations.sort((a, b) => a - b);
let left = 0;
let right = citations.length - 1;
while (left <= right) {
const mid = (left + right) >> 1;
if (citations[mid] < citations.length - mid) {
left = mid + 1;
} else {
right = mid - 1;
}
}
return citations.length - left;
};
274. H-Index
给定一位研究者论文被引用次数的数组(被引用次数是非负整数),数组已经按照 升序排列。编写一个方法,计算出研究者的
h
指数。h 指数的定义: h 代表“高引用次数”(high citations),一名科研人员的 h 指数是指他(她)的 (N 篇论文中)总共 有 h 篇论文分别被引用了 至少 h 次。(其余的 N - h 篇论文每篇被引用次数 不超过 h 次。)
Example
Note