Java O(n)

  • 0

    public int hIndex(int[] citations) {
    int ans = 0;
    for(int i=citations.length-1;i>=0;i--){
    if(citations[i] >= citations.length-i){
    if(ans < citations.length-i)
    ans = citations.length-i;
    return ans;

    I think my ans is very simple, but so many logn, I'm naive.......

Log in to reply

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