public int[] searchRange(int[] A, int target) {


        int[] out = {-1, -1};
        if (A == null || A.length == 0)
            return out;
        int start = 0;
        int end = A.length - 1;
        while (start <= end) {
            int mid = start + (end - start)/2;
            if (A[mid] < target)
                start = mid + 1;
            else if (A[mid] > target)
                end = mid - 1;
            else {
                int idx = mid;
                while (idx > 0 && A[idx-1] == target)
                    idx--;
                out[0] = idx;
                idx = mid;
                while (idx < A.length-1 && A[idx+1] == target)
                    idx++;
                out[1] = idx;
                    
                
                break;
            }
                
        }
        
        return out;
    }