private boolean binarySearch(int[] A, int start, int end, int target) {
            if (start > end) {
                return false;
            }
            int middle = start + (end - start) / 2;
            if (A[middle] == target) {
                return true;
            }
            // Find the correct sequence.
            if (A[start] < A[middle] || A[start] == A[middle] && check(A, start, middle)) {
                if (A[start] <= target && target < A[middle]) {
                    return binarySearch(A, start, middle - 1, target);
                } else {
                    return binarySearch(A, middle + 1, end, target);
                }
            } else {
                if (A[middle] < target && target <= A[end]) {
                    return binarySearch(A, middle + 1, end, target);
                } else {
                    return binarySearch(A, start, middle - 1, target);
                }
            }
        }