PROGRAMMERS_Lv2_H-Index
π [Lv2_42747] H-Index
import java.util.*;
class Solution{
public int solution(int[] citations) {
int answer = 0;
// μ λ ¬
Arrays.sort(citations);
int size = citations.length;
// κ° μ°ΎκΈ°
for(int i=0; i<size;i++){
int temp = size-i;
if(citations[i] >= temp){
answer = temp;
break;
}
}
return answer;
}
}
π€ λμ μκ°
μ λ ¬ ν κ°μ₯ μ²μ μΈμ©λ λ
Όλ¬Έμ΄ λ°°μ΄κ°μ λλ κ²½μ° λ !
int[] μ λ ¬μ Arrays.sort(), List μ λ ¬μ Collections.sort(), λ°λλ Collections.sort(list, Comparator.reverseOrder())