Skip to content

Commit f9209ac

Browse files
Create Lonely integer.cpp
1 parent 12cc86e commit f9209ac

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Hackerrank/Lonely integer.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int findSingle(int ar[], int ar_size)
5+
{
6+
int res = ar[0];
7+
for (int i = 1; i < ar_size; i++)
8+
res = res ^ ar[i];
9+
10+
return res;
11+
}
12+
13+
int main()
14+
{ int arr[100000];
15+
int n;
16+
cin>>n;
17+
for(int i=0; i<n;i++)
18+
{
19+
cin>>arr[i];
20+
}
21+
cout<< findSingle(arr, n);
22+
return 0;
23+
}

0 commit comments

Comments
 (0)