ExamAdda Logo

H Index

Easy

Given an integer array citations where citations[i] is the number of citations received by the ith paper, return the researcher's h-index.

The h-index is defined as the maximum value h such that the researcher has published at least h papers that have each been cited at least h times.

Example 1

Input

5
3 0 6 1 5

Output

3

Explanation

The researcher has 3 papers with at least 3 citations each (6, 5, and 3).

Therefore, the h-index is 3.

Example 2

Input

4
1 3 1 2

Output

2

Explanation

There are 2 papers with at least 2 citations each.

Hence, the h-index is 2.

Constraints

1 ≤ citations.length ≤ 5000
0 ≤ citations[i] ≤ 1000

Hints:

Hint 1

Sort the citations in descending order and count how many papers have citations greater than or equal to their position.

Hint 2

The h-index is the largest value h such that there are at least h papers with h or more citations.

Author & Technical Reviewer

ExamAdda Technical Review Team

Technically reviewed by: ExamAdda Technical Review Team

Technical Reviewers, ExamAdda

Software engineers at ExamAdda who check every article's definitions, complexity claims and code examples before and after publishing.

Published

Aug 4, 2026

Last updated

Aug 4, 2026

Content Verification Methodology

Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.

Report a correction:editorial@examadda.org
Auto
Loading editor...
Input

Expected Output