"Find the two non-repeating elements in an array of repeating elements/ Unique Numbers 2" Code Answer's
You're definitely familiar with the best coding language C++ that developers use to develop their projects and they get all their queries like "Find the two non-repeating elements in an array of repeating elements/ Unique Numbers 2" answered properly. Developers are finding an appropriate answer about Find the two non-repeating elements in an array of repeating elements/ Unique Numbers 2 related to the C++ coding language. By visiting this online portal developers get answers concerning C++ codes question like Find the two non-repeating elements in an array of repeating elements/ Unique Numbers 2. Enter your desired code related query in the search bar and get every piece of information about C++ code related question on Find the two non-repeating elements in an array of repeating elements/ Unique Numbers 2.
Find the two non-repeating elements in an array of repeating elements/ Unique Numbers 2
#include <iostream>
using namespace std;
int main()
{
int n;
cout<<"enter the size of the array:"<<endl;
cin>>n;
int arr[n];
cout<<"enter the elements of the array:"<<endl;
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
int res=0;
int x=0;
int y=0;
int setbit;
for(int i=0;i<n;i++)
{
res=res^arr[i];
}
setbit=res&(~(res)+1);
for(int i=0;i<n;i++)
{
if(arr[i]&setbit) //xor the first set
{
x=x^arr[i];
}
else //xor the second set
{
y=y^arr[i];
}
}
cout<<x<<" "<<y<<endl;
return 0;
}
All those coders who are working on the C++ based application and are stuck on Find the two non-repeating elements in an array of repeating elements/ Unique Numbers 2 can get a collection of related answers to their query. Programmers need to enter their query on Find the two non-repeating elements in an array of repeating elements/ Unique Numbers 2 related to C++ code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about Find the two non-repeating elements in an array of repeating elements/ Unique Numbers 2 for the programmers working on C++ code while coding their module. Coders are also allowed to rectify already present answers of Find the two non-repeating elements in an array of repeating elements/ Unique Numbers 2 while working on the C++ language code. Developers can add up suggestions if they deem fit any other answer relating to "Find the two non-repeating elements in an array of repeating elements/ Unique Numbers 2". Visit this developer's friendly online web community, CodeProZone, and get your queries like Find the two non-repeating elements in an array of repeating elements/ Unique Numbers 2 resolved professionally and stay updated to the latest C++ updates.