Java - 5 lines of code - Clean


  • 0

    public int hIndex(int[] citations) {
    Arrays.sort(citations);
    if(citations.length == 0) return 0; int cit = 0;
    for(int i = 0; i < citations.length; i++){
    if((citations.length - i) <= citations[i]) cit = Math.max(cit, (citations.length - i));
    }
    return cit;
    }


Log in to reply
 

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