H-Index
You get the citation counts of a researcher's papers. Their h-index is the largest h such that h of the papers have at least h citations each. Find it. Our example: [6, 0, 3, 11, 1, 5] — the answer is 3: four papers have at least 3 citations, but only three have at least 4.
- input
citations: how many times each paper of a researcher was cited.- returns
- The h-index: the largest
hsuch that at leasthpapers were each cited at leasthtimes. - constraints
- 1 ≤ citations.length ≤ 5000
- 0 ≤ citations[i] ≤ 1000
- examples
- Open a test in the tests panel: it shows the input and the expected answer.
/**
* @param {number[]} citations
* @return {number}
*/
function hIndex(citations) {
}
Ctrl ↵
format
reset
saved in this browser
Stuck?
See the solution run step by step on our example, then why it works and its complexity.
Next: more binary search problems
- 704Binary SearchEasysolve
- 35Search Insert PositionEasysolve
- 69Sqrt(x)Easysolve
- 153Find Minimum in Rotated Sorted ArrayMediumsolve
- 33Search in Rotated Sorted ArrayMediumsolve
- 875Koko Eating BananasMediumsolve
- 1011Capacity To Ship Packages Within D DaysMediumsolve
- 74Search a 2D MatrixMediumsolve
- 162Find Peak ElementMediumsolve
- 34Find First and Last Position of Element in Sorted ArrayMediumsolve
- 4Median of Two Sorted ArraysHardsolve
The problem and its statement belong to LeetCode. Here are our own retelling, example and solution. Patterns Hero is not affiliated with LeetCode.