Level2) H-Index
2021. 5. 4. 14:05ㆍPS/programmers
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;
public class Level2_HIndex {
public static int solution(int[] citations) {
Arrays.sort(citations);
int hIndex = 0;
int n = citations.length;
for (int i = 0; i < n; i++) {
int h = n - i;
if (citations[i] >= h) {
hIndex = h;
break;
}
}
return hIndex;
}
public static void main(String[] args) {
int[] citations = {3, 0, 6, 1, 5};
System.out.println(solution(citations));
}
}
|
cs |
문제 이해가 잘 안가서 찾아서 풀었다.
아직도 좀 헷갈린다.
h 는 citations[] 배열의 수가 아니여도 된다.
n편의 논문중 h 번 이상 인용된 논문이 h 편 이상인 h 의 최댓값을 찾는다.
'PS > programmers' 카테고리의 다른 글
MySQL 1레벨 다 풀었다. (0) | 2021.08.06 |
---|---|
Level2) 카펫 (0) | 2021.07.13 |
Level2) 위장 (0) | 2021.05.03 |
Level1) 내적 (0) | 2021.05.02 |
Level1) 폰켓몬 (0) | 2021.05.01 |