citations
를 내림차 순으로 정렬하여 H-Index를 구하기 용이한 순서로 정의citations
순회h + 1
보다 작은 인용 수를 갖는다면 해당 h
가 H-Index 이므로 반복문 종료h
증가h
반환function hIndex(citations: number[]): number {
citations.sort((a, b) => b - a);
let h = 0;
for (let i = 0; i < citations.length; i++) {
if(citations[i] < h + 1) break
h++
}
return h;
}