H-Index

Medium

Topics
ArraySortingCounting Sort

Given an array citations where citations[i] is the number of citations for the i-th paper, return the researcher's h-index: the maximum h such that h papers have at least h citations each.

Example 1

Input:  citations = [3,0,6,1,5]
Output: 3

Example 2

Input:  citations = [1,3,1]
Output: 1

Constraints

  • n == citations.length
  • 1 <= n <= 5000
  • 0 <= citations[i] <= 1000
Run ⌘' · Submit ⌘⏎