public static int[] searchRange(int[] A, int target) {
        int res[] = new int[2], bt = 0, ed = A.length - 1, mid = 0;

        while (bt <= ed) {
            mid = bt + ((ed - bt) >> 1);
            if (A[mid] == target) {
                break;
            } else if (A[mid] > target) {
                ed = mid - 1;
            } else {
                bt = mid + 1;
            }
        }

        if (bt > ed) { // not found
            res[0] = res[1] = -1;
        } else { // found
            int is, ie;

            is = mid;
            while (is - 1 >= 0 && A[is - 1] == target) {
                is -= 1;
            }

            ie = mid;
            while (ie + 1 < A.length && A[ie + 1] == target) {
                ie += 1;
            }

            res[0] = is;
            res[1] = ie;
        }

        return res;
    }