274. H-Index
in Coding Interview on Array, Sort
연구원의 h-index를 반환
- h-index는 주어진 연구자가 각각 적어도 h번 인용된 적어도 h개의 논문을 발표한 h의 최대값으로 정의
Sorting Solution
class Solution {
public int hIndex(int[] citations) {
// sorting the citations in ascending order
Arrays.sort(citations);
// finding h-index by linear search
int i = 0;
while (i < citations.length && citations[citations.length - 1 - i] > i) {
i++;
}
return i; // after the while loop, i = i' + 1
}
}