int comp( const int*l, const int*r )
{
if( l[0]!=l[1] )
return 1;
if( r[0]!=r[1] )
return 1;
return 0;
}
int singleNonDuplicate(int* nums, int numsSize) {
qsort( nums, (numsSize+1)/2, sizeof(nums[0])+sizeof(nums[0]), (int (*)(const void*,const void*)) comp );
return nums[0];
}
C 3ms solution without while/loop.


for example
[1,1,2,3,3]
[1,1,2,3,3,4,4]
[1,1,2,3,3,3,3,4,4]We cat treat it as int pair:
[1,1], [2,3], [3,]
[1,1], [2,3], [3,4], [4, ]
[1,1], [2,3], [3,3], [3,4], [4, ]The answer will always be the 1st (and also smallest) in different pair
Thus, qsort can simply work fine and quickly.This solution is not a regular one, but it works just fine on this very condition.