public int hIndex(int[] citations) {
        int[] count = new int[citations.length + 1];
        for (int c : citations) {
            if (c <= citations.length) {
                count[c]++;
            } else {
                count[citations.length]++;
            }
        }

        int sum = 0;
        int max = 0;
        for (int i = 0; i < count.length; i++) {
            sum += count[i];
            //we are trying to see if i is answer.
            //already everything before i has less than i citations.
            //so only thing to check is that p >= i where p is
            //total number of papers with i or more citations.
            int p = citations.length - sum + count[i];
            if (i <= p) {
                max = i;
            }
        }
        return max;
    }
Given an array of citations (each citation is a non-negative integer) of a researcher,
write a function to compute the researcher's h-index.
https://leetcode.com/problems/h-index/
src/com/interview/array/HIndex.java