Given an integer array nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. You can return the answer in any order.

You must write an&nbsp;algorithm that runs in linear runtime complexity and uses&nbsp;only constant extra space.

&nbsp;
Example 1:

Input: nums = [1,2,1,3,2,5]
Output: [3,5]
Explanation:  [5, 3] is also a valid answer.


Example 2:

Input: nums = [-1,0]
Output: [-1,0]


Example 3:

Input: nums = [0,1]
Output: [1,0]


&nbsp;
Constraints:


	2 &lt;= nums.length &lt;= 3 * 104
	-231 &lt;= nums[i] &lt;= 231 - 1
	Each integer in nums will appear twice, only two integers will appear once.


class Solution:
    def singleNumber(self, nums: List[int]) -> List[int]:
        x = Counter(nums)
        return([y for y in x if x[y] == 1])
class Solution {
    public int[] singleNumber(int[] nums) {
        if (nums == null || nums.length < 2 || nums.length % 2 != 0) {
            throw new IllegalArgumentException("Invalid Input");
        }

        int aXORb = 0;
        for (int n : nums) {
            aXORb ^= n;
        }

        int rightSetBit = aXORb & -aXORb;
        int a = 0;
        for (int n : nums) {
            if ((n & rightSetBit) != 0) {
                a ^= n;
            }
        }

        return new int[] {a, aXORb ^ a};
    }
}
class Solution {
public:
    vector<int> singleNumber(vector<int>& nums){
        vector<int> ans;
        int xorr = 0;
        for(int i=0; i<nums.size(); i++){
            xorr = xorr xor nums[i];
        }
        int count  = 0;
        while(xorr){
            if(xorr & 1){
                break;
            }
            count++;
            xorr = xorr >> 1;
        }
        int xorr1 = 0;
        int xorr2 = 0;
        for(int i=0; i<nums.size(); i++){
            if(nums[i] & (1 << count)){
                xorr1 = xorr1 xor nums[i];
            }
            else{
                xorr2 = xorr2 xor nums[i];
            }
        }
        ans.push_back(xorr1);
        ans.push_back(xorr2);
        return ans;
    }
};
var singleNumber = function(nums) {
    let hash ={}
    for ( let num of nums){
        if( hash[num]===undefined)
            hash[num] =1
        else
            hash[num]++
    }

    let result =[]
    for ( let [key, value] of Object.entries(hash)){
         if(value==1)
         result.push(key)
    }
    return result
};
Single Number III