private void binarySearch(int[] A, int left, int right, int target, int[] result) {
        // not exist
        if (left > right) {
            result[0] = -1;
            result[1] = -1;
            return;
        }

        int middle = (left + right) / 2;
        if (target == A[middle]) {
            int start = middle;
            int end = middle;
            while (start > 0) {
                if (target == A[start - 1]) {
                    start--;
                } else {
                    break;
                }
            }

            while (end < A.length - 1) {
                if (target == A[end + 1]) {
                    end++;
                } else {
                    break;
                }
            }
            result[0] = start;
            result[1] = end;
        } else if (target < A[middle]) {
            binarySearch(A, left, middle - 1, target, result);
        } else if (target > A[middle]) {
            binarySearch(A, middle + 1, right, target, result);
        }
    }