public int binarySearch(int begin, int end, int[] A, int target, boolean isLeft) {
		if (begin > end) {
			return -1;
		}
		int mid = (begin + end) >> 1;
		if (A[mid] == target) {
			if (isLeft) {
				int left = binarySearch(begin, mid - 1, A, target, isLeft);
				return left == -1? mid : mid < left ? mid : left;
			} else {
				int right = binarySearch(mid + 1, end, A, target, isLeft);
				return right == -1 ? mid :mid > right ? mid : right;
			}
		}
		if (A[mid] > target) {
			return binarySearch(begin, mid - 1, A, target, isLeft);
		} else {
			return binarySearch(mid + 1, end, A, target, isLeft);
		}
	}