-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution15.java
More file actions
28 lines (24 loc) · 1011 Bytes
/
Solution15.java
File metadata and controls
28 lines (24 loc) · 1011 Bytes
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
26
27
28
/* 코딩 테스트 공부 - 15
* 어떤 과학자가 발표한 논문 n편 중, h번 이상 인용된 논문이 h편 이상이고 나머지 논문이 h번 이하 인용되었다면 h의 최댓값이 이 과학자의 H-Index입니다.
* 어떤 과학자가 발표한 논문의 인용 횟수를 담은 배열 citations가 매개변수로 주어질 때, 이 과학자의 H-Index를 return 하도록 solution 함수를 작성해주세요.
*/
package codingTest;
import java.util.Arrays;
public class Solution15 {
public static int solution(int[] citations) {
int answer = 0;
Arrays.sort(citations);
for(int i = 0; i < citations.length; i++){
int h = citations.length - i;
if(citations[i] >= h){
answer = h;
break;
}
}
return answer;
}
public static void main(String[] args) {
int[] arr = {3, 0, 6, 1, 5};
System.out.println(solution(arr));
}
}