PROBLEM DESCRIPTION
Given a sorted array arr[] of size N. Find the element that appears only once in the array. All other elements appear exactly twice.
SOLUTION
1
2
3
4
5
6
7
8
9
10
class Solution
{
int findOnce(int arr[], int n)
{
int x = arr[0];
for(int i=1; i<n; i++)
x = x ^ arr[i];
return x;
}
}