My Java Solution


  • 0
    D

    This is my solution that uses the built in Arrays.sort(int[]) method.

    public class Solution {
        public int hIndex(int[] citations) {
            Arrays.sort(citations);
            for (int h = citations.length; h > 0; h--) {
                int below = citations.length - h;
                if (citations[below] < h) {
                    continue;
                } else {
                    return h;
                }
            }
            return 0;
        }
    }

Log in to reply
 

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