Java O(nlogn) solution


  • 0
    J
        public int hIndex(int[] citations) {
            Arrays.sort(citations);
            int len = citations.length;
            int mx = 0;
            for(int i = len-1; i >= 0 ; i--){
                if(citations[len - 1 - i] >= i+1) mx = Math.max(mx,i+1);
            }
            return mx;
        }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.