FunctionRacerProblemsRace

H-Index

MediumSorting and searchingPython, JavaScript, TypeScript, Java, C++

Item citations[i] of the list citations is how many times a researcher's paper i was cited. The h-index is the largest number h such that at least h papers have h or more citations each.

Return the h-index.

Example 1

citations [3,0,6,1,5]
returns 3

Three papers (3, 6, 5) have at least 3 citations, but not four with 4, so h = 3.

Example 2

citations [0,0]
returns 0

h = 0.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Sorting and searching problems