[ 프로그래머스 ] #42747 : H-Index - JAVA

🔗 H-Index

import java.util.Arrays;
class Solution {
    public int solution(int[] citations) {
        Arrays.sort(citations);  // 오름차순 정렬
        int n = citations.length;

        for (int i = 0; i < n; i++) {
            // 개수
            int h = n - i;
            // 인용 횟수
            int count = citations[i];
            // 인용 횟수가 h편 이상이라면 
            if (citations[i] >= h) {
                return h;
            }
        }

        return 0;
    }
}