Find the Number Occurring Odd Number of Times
/*
https://ideone.com/KmVVHQ
http://www.geeksforgeeks.org/find-the-number-occurring-odd-number-of-times/
*/
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t, n;
cin >> t;
while(t--){
cin >> n;
int a[n];
for(int i=0; i<n; i++)
cin >> a[i];
for(int i=0; i<n; i++){
int count = 0;
for(int j=0; j<n; j++){
if(a[i] == a[j])
count++;
}
if(count % 2 != 0){
cout << a[i] << endl;
break;
}
}
}
return 0;
}/*
https://ideone.com/RQo8jN
http://www.geeksforgeeks.org/find-the-number-occurring-odd-number-of-times/
*/
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t, n;
cin >> t;
while(t--){
cin >> n;
int a[n];
for(int i=0; i<n; i++)
cin >> a[i];
int count[50] = {};
for(int i=0; i<n; i++){
count[a[i]]++;
}
for(int i=0; i<50; i++){
if(count[i] % 2 != 0){
cout << i << endl;
break;
}
}
}
return 0;
}/*
http://ideone.com/ZmW24e
http://www.geeksforgeeks.org/find-the-number-occurring-odd-number-of-times/
http://www.practice.geeksforgeeks.org/problem-page.php?pid=836
*/
#include <iostream>
using namespace std;
int main() {
int t, n, x;
cin >> t;
while(t--){
cin >> n;
int odd = 0;
while(n--){
cin >> x;
odd = odd ^ x;
}
cout << odd << endl;
}
return 0;
}