3 line solution and better than the solution given as a hint


#1

Arrays.sort(A);
for(int i=0;i<A.length-1;i+=2){
if(A[i]!=A[i+1]){
return A[i];
}
}


#2

Not linear runtime though. Sorting needs nlog(n)


#3

Motive shouldn’t be just doing the program, it should be doing efficiently.


#5

don’t post this kind of solution just for the sake of bragging…you might haven’t noticed that const vector is given which indicates sorting is not the approach here… Everyone can do with sorting isn’t a big deal…