‹ DS&A interview · Socratic
DSA · Arrays & Sorting · #81

H-Index

Module 64 · difficulty 3/5·30:00starts on first keystroke

Given an array `citations` where `citations[i]` is the number of citations a researcher received for their `i`-th 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. Implement the function `hIndex(citations)` returning an integer.

Examples
  • citations = [3,0,6,1,5] 3There are 3 papers with at least 3 citations each (3, 6, 5), and the remaining two have no more than 3 citations each.
  • citations = [1,3,1] 1
  • citations = [0] 0A single uncited paper gives an h-index of 0.
Constraints
  • · n == citations.length
  • · 1 <= n <= 5000
  • · 0 <= citations[i] <= 1000
Session phases
A · Clarify
B · Approach
C · Complexity
D · Edges
E · Code
F · Tradeoff
G · Score
Phase A — Clarify
Ask questions about input bounds, types, and edge constraints.
Ask the coach clarifying questions about the problem.
When you've covered this phase, advance to the next.