public int[] searchRange(int[] A, int target) {
        int[] res = new int[2];
        if(A == null || A.length == 0) return res;
        int pos = binarySearch(A, target, 0, A.length-1);
        if(pos == -1) {
            res[0] = res[1] = -1;
        } else {
            int start = 0, end = pos;
            while(start <= end) {
                int mid = (end - start) / 2 + start;
                if(A[mid] == target) end = mid - 1;
                else start = mid + 1;
            }
            res[0] = start;
            
            start = pos;
            end = A.length - 1;
            while(start <= end) {
                int mid = (end - start) / 2 + start;
                if(A[mid] == target) start = mid + 1;
                else end = mid - 1;
            }
            res[1] = end;
        }
        return res;
    }