Accepted Java solution (252 ms)


  • 0
    P
    public class Solution {
        Integer max = null;
        public int hIndex(int[] citations) {
            if(citations==null || citations.length==0) return 0;
            Arrays.sort(citations);
            int i = 0;
            for(i=0;i<citations.length;i++)
            {
                if(citations[i] >= (citations.length-i)) break;
            }
            if(i==citations.length) return 0;
            return Integer.min(citations[i],(citations.length-i));
            
        }
    }

Log in to reply
 

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