package leetcode;

/**
 * https://leetcode.com/problems/h-index-ii/
 */
public class Problem275 {
    public int hIndex(int[] citations) {
        int idx = binarySearch(citations, 0, citations.length-1);
        return citations.length - idx;
    }

    private int binarySearch(int[] citations, int lo, int hi) {
        if (lo > hi) {
            return lo;
        }
        int mid = (lo + hi) / 2;
        if (citations[mid] == citations.length-mid) {
            return mid;
        }
        if (citations[mid] > citations.length-mid) {
            return binarySearch(citations, lo, mid-1);
        }
        return binarySearch(citations, mid+1, hi);
    }

    public static void main(String[] args) {
        Problem275 prob = new Problem275();
    }
}

@@ -663,103 +663,7 @@
    %7D
-%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem275 prob = new Problem275();%0A    %7D
 %0A%7D%0A

Update problem 275