O(n) time java solution


  • 0
    J
        public int hIndex(int[] citations) {
            int len = citations.length, 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.