Problem Solving/Programmers

[Level 2] H-Index

kmkunk 2022. 4. 6. 11:26
import java.util.*;

class Solution {
    public int solution(int[] citations) {
        int answer = 0;
        
        Arrays.sort(citations);
        
        for(int i=0; i<=citations.length; i++) {
            for(int j=0; j<citations.length; j++) {
                if(citations[j]>=i && citations.length-j>=i) {
                    answer = i;
                    break;
                }
            }
        }
        
        return answer;
    }
}