


Input: 'arr' = [1,1,2,2,4,5,5]
Output: 4
Explanation:
Number 4 only appears once the array.
Exactly one number in the array 'arr' appears once.
The first line contains a single integer ‘n’, representing the total number of elements present in the array 'arr'.
The next line contains ‘n’ single-spaced elements, representing the elements of the array 'arr'.
The only line contains the integer denoting the number that appears once in the array.
##### Note : You do not need to print anything, it has already been taken care of. Just implement the given function.
The idea here is to use the fact that the array is sorted and the element of the array (‘arr[i]’) is unique if it doesn't have an adjacent element that has the same value as ‘arr[i]’.
Algorithm:
The idea here is to store the frequency of elements of the array in a hashmap. Then we will traverse all elements of hashMap and the element whose frequency is 1 will be our answer.
Algorithm:
The idea here is to use the fact that the bitwise xor of two numbers is zero. So, we will do the xor of all elements of the array, and all the numbers which occur twice get canceled out. So, in the end, we will get the number that occurs only once.
For example
Array = [1, 1, 3, 3, 5, 7, 7]
Here 1 ^ 1 ^ 3 ^ 3 ^ 5 ^ 7 ^ 7 = 5
As 1 ^ 1 = 3 ^ 3 = 7 ^ 7 = 0
Algorithm:
The idea here is to use binary search and move left and right using the below observation.
Algorithm: