Java solution with sorting N(lgN)


  • 1
    Q
    public class Solution {
        public int hIndex(int[] citations) {
            Arrays.sort(citations);
            int maxCit = 0;
            for (int i=0;i<citations.length;i++){
                int cit = Math.min(citations[i], citations.length-i);
                if (cit >= maxCit ){
                    maxCit = cit;
                    continue;
                }
                break;
            }
            return maxCit;
        }
    }

Log in to reply
 

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