Problem 275

Posted by Ruizhi Ma on November 4, 2020

Solution URL

https://leetcode.com/submissions/detail/416520573/

代码

class Solution {
    public int hIndex(int[] citations) {
        //ans: Solution
        Arrays.sort(citations);

        int i = 0;
        int len = citations.length;
        while(i < len && citations[len - i - 1] > i){
            i++;
        }

        return i;//after loop, i comes to i+1
    }
}