Find the element that appears once
Given an array where every element occurs two times, except one element which occurs only once. Find the element that occurs once?
By using Brute Force technique, search for element which appeared once using two loops.
Complexity: O (n^2).
1. Sort the number.
2. Search for the element appeared once.
Complexity: O (nLogn).
Make a hashmap which will maintain the count of each digit.
Complexity: Worst case time of hashing may be more than O (n) and hashing requires extra space.
XOR all the elements of the array and the result will be the element which appeared once.
Complexity: O (n).