the code is running perfectly fine…but isn’t getting submitted .what’s wrong with this code.https://ide.codingblocks.com/s/99493
Unique number || problem
//given an array which consists of all the elements twice except two elements .find those unique numbers. #include<bits/stdc++.h> using namespace std; void findunique(int *a,int n) { int res=0,mask=0; for(int i=0;i<n;i++) { res=res^a[i]; } int i=0; int temp=res; while(temp!=0) { if ((temp&1)==1) { break; } i++; temp=temp>>1; } mask=1<<i; int firstno=0; for(i=0;i<n;i++) { if((mask&a[i])!=0) { firstno=firstno^a[i]; } } int secondno=firstno^res; cout<<firstno<<" "<<secondno<<endl; } int main() { int n,i; cin>>n; if(n<pow(10,5)) { int a[n]; for(i=0;i<n;i++) { cin>>a[i]; } findunique(a,n); } return 0; }
provide correct code link…
you cant run loop till 1e18 … use principle of inclusion and exclusion…
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.