four-line Java code


  • 0
    H
    public int hIndex(int[] citations) {
            Arrays.sort(citations);
            int len = citations.length, res = 0;
            for (int citation : citations) res = Math.max(res, Math.min(citation, len --));
            return res;
        }
    

Log in to reply
 

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