H-Index


프로그래머스 [H-Index]

문제보기
Alt text

소스코드

import java.util.Arrays;

class Solution {
  public static int solution(int[] citations) {
       Arrays.sort(citations);

        int n = citations.length;

        int hIndex = 0;
        for (int i = n - 1; i >= 0; i--) {
            int thesisCnt = n - i;
            int citation = citations[i];

            if (thesisCnt <= citation) {
                hIndex = thesisCnt;
            } else {
                break;
            }
        }

        return hIndex;
    }
}