My easy Java solution O(n)


  • 0
    W

    '''
    public class Solution {
    public int hIndex(int[] citations) {
    int l=citations.length,i;
    int[] count=new int[l+1];
    for(i=0;i<l;i++){
    if(citations[i]>=l) count[l]++;
    else count[citations[i]]++;
    }
    int h=count[l];
    while(h<i){
    h+=count[--i];
    }
    return i;
    }
    }
    '''


Log in to reply
 

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