[Algorithm - Programmers] H-Index

nunu·2023년 12월 17일
0

Algorithm

목록 보기
118/142

https://school.programmers.co.kr/learn/courses/30/lessons/42747

제출 코드

import java.util.Arrays;
class Solution {
    public 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;
    }
}
profile
Hello, I'm nunu

0개의 댓글