11 lines Java code


  • 0
    A

    public class Solution {
    public int hIndex(int[] citations) {
    Arrays.sort(citations);
    int ans=0;
    for(int i=0; i<citations.length; i++){
    int h = citations[i]>(citations.length-i) ? (citations.length-i) : citations[i];
    ans = ans>h ? ans : h;
    }
    return ans;
    }
    }


Log in to reply
 

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