Unique number 1


what is wrong in this code.
pls tell in the form of a code

@yutikakhanna
Hello Yutika,
ok 1 second ,i am debugging ur code

@yutikakhanna
hello yutika,
checkout your code- https://ide.codingblocks.com/s/178727

  1. it will not pass one test case because in that test case some elements are repeated more than twice which is against the problem statement

also try to do the same problem using bitwise

@yutikakhanna
Hint to solve it using bitwise - xor of a number with itself is always zero

can you pls provide the correct code or do changes in the same

@yutikakhanna
just take xor of all elements and print it

@yutikakhanna
#include < iostream >
using namespace std;
int main() {
int n;
cin>>n;
int ans=0,k,i;
for(i=0;i<n;i++)
{
cin>>k;
ans=ans^k;
}
cout<<ans<<endl;
return 0;
}

tried the same but getting many errors. can u tell in the form of a code

@yutikakhanna
check this - https://ide.codingblocks.com/s/178771

@yutikakhanna
if you have any other doubt then feel free to ask if not then pls mark ur doubt as resolved

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.