
난이도 : Level 2
정답률: 63%
▶ 문제

▶ 풀이
정답률에 비해 쉽게 풀었다. count 가 h 번 인용된 논문이 h 편 이상인 최댓값이기 때문에 최댓값부터 감소시키며 계산했다.
function solution(citations) {
let h = citations.length + 1;
let count = 0;
while(h--) {
count = 0;
citations.forEach(x => {
if(h <= x) {
count++;
}
})
if(count >= h) {
return h;
}
}
}
'코테' 카테고리의 다른 글
| [Algorithm] 귤 고르기 - JavaScript (0) | 2024.02.26 |
|---|---|
| [Algorithm] 행렬의 곱셈 - JavaScript (0) | 2024.02.24 |
| [Git] 백준 / 프로그래머스 Git 연동 (0) | 2024.01.24 |
| [Algorithm] 괄호 회전하기 - JavaScript (1) | 2024.01.23 |
| [Algorithm] 행렬의 곱셈 - JavaScript (2) | 2024.01.23 |