We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d3ebaa6 commit 52dfb61Copy full SHA for 52dfb61
bona1122/[week9]Sort/H_index.js
@@ -0,0 +1,16 @@
1
+// https://school.programmers.co.kr/learn/courses/30/lessons/42747
2
+// 핵심: 논문을 인용 횟수 기준 내림차순으로 정렬한 후,
3
+// 논문의 개수(인덱스+1)가 해당 논문의 인용 횟수보다 작거나 같은 최대 지점을 찾는 것
4
+
5
+function solution(citations) {
6
+ citations = citations.sort((a, b) => b - a)
7
8
+ let i = 0 // 현재까지 확인한 논문의 인덱스
9
+ // i+1 <= citations[i]가 참이면:
10
+ // "i+1번 이상 인용된 논문이 i+1편 이상"이라는 의미
11
+ while (i + 1 <= citations[i]) {
12
+ i++
13
+ }
14
15
+ return i
16
+}
0 commit comments