Skip to main content
Back to problems
Leetcode
Medium
Arrays
Sorting
Greedy
Google
Amazon
Microsoft
274. H-Index

Compute the largest h such that at least h papers have at least h citations.

Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.

H-Index

gfg
Problem Statement

You are given an array of non-negative integers representing citation counts for a researcher’s papers. Find the researcher's H-index.

The H-index is the largest integer hh such that the researcher has at least hh papers with at least hh citations each.

Your task is to return that maximum value.

Input Format

  • A single integer array citations where citations[i] is the citation count of the ii-th paper.

Output Format

  • Return a single integer: the H-index.

Constraints

  • 1 <= citations.length <= 5000
  • 0 <= citations[i] <= 1000
  • The answer is always a valid integer in the range [0, citations.length]
Examples
Sample cases returned by the problem API.

Example 1

Input

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

Output

3

Explanation

There are 3 papers with at least 3 citations each: 3, 5, and 6. There are not 4 papers with at least 4 citations each.

Example 2

Input

citations = [1,3,1]

Output

1

Explanation

At least 1 paper has at least 1 citation, but there are not 2 papers with at least 2 citations.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.