Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

unique element in array in c

//using XOR
//you can fact check it on https://xor.pw/
#include<bits/stdc++.h>
using namespace std;
 
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
 
  int n,x,num=0;
  cin>>n;
  while(n--){
      cin>>x;
      num^=x;
  }
  cout<<num<<'
';

    return 0;
}
 
PREVIOUS NEXT
Tagged: #unique #element #array
ADD COMMENT
Topic
Name
2+6 =