private int higherHelper(int[] A, int target, int left, int right) {

    if (left > right) {
      return -1;
    }

    int mid = (left + right) / 2;
    int midVal = A[mid];
    if (midVal == target) {
      if (mid == A.length - 1 || A[mid + 1] > target) {
        return mid;
      }
      return higherHelper(A, target, mid + 1, right);
    } else if (midVal < target) {
      return higherHelper(A, target, mid + 1, right);
    } else {
      return higherHelper(A, target, left, mid - 1);
    }
  }