반응형
programmers.co.kr/learn/courses/30/lessons/42747?language=java
코딩테스트 연습 - H-Index
H-Index는 과학자의 생산성과 영향력을 나타내는 지표입니다. 어느 과학자의 H-Index를 나타내는 값인 h를 구하려고 합니다. 위키백과1에 따르면, H-Index는 다음과 같이 구합니다. 어떤 과학자가 발표
programmers.co.kr
Solution
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import java.util.Arrays;
class Solution {
public int solution(int[] citations) {
int answer = 0;
int len = citations.length;
int h = 1;
int cur = 0;
Arrays.sort(citations);
for(int i=0 ; i<len ; i++){
if(h <= citations[cur]) {
answer = h;
h++;
}else {
cur++;
}
if(h > len-cur) break;
}
return answer;
}
}
|
cs |

반응형
'코딩테스트 > 프로그래머스' 카테고리의 다른 글
프로그래머스 - 월간 코드 챌린지 시즌1 > 삼각 달팽이 (0) | 2021.03.28 |
---|---|
프로그래머스 - [Level 2]코딩테스트 연습 > 정렬 > 가장 큰 수 (0) | 2021.03.28 |
프로그래머스 - [Level 1]코딩테스트 연습 > 정렬 > K번째수 (0) | 2021.03.27 |