I have a question and I tried to think over it again and again... but got nothing so posting the question here. Maybe I could get some view-point of others, to try and make it w
Try this:
int getOddOccurrence(int ar[], int ar_size) { int i; int xor = 0; for (i=0; i < ar_size; i++) xor = xor ^ ar[i]; return res; }
XOR will cancel out everytime you XOR with the same number so 1^1=0 but 1^1^1=1 so every pair should cancel out leaving the odd number out.