Find two unique integers in sorted array
For each number in the list, either


there is no next (at end of src list) - add to result list
the next is different - add to the result list, increment result count (if all answers found, return)
the next is the same; skip next, (add 2 to src pointer)


public int[] findUnique(int[] src){
    int[] res =  new int[2];
    int resIdx = 0;

    for(int i = 0; i &lt; src.length;){
        // at the end of the list, or next is different
        if(i == src.length-1 || src[i] != src[i+1]){
            res[resIdx++] = src[i++];
            if (resIdx== 2) break;
        } else{
            // not different; skip next item
            i+=2;
        }
    }
    return res;
}