Given an integer array nums where&nbsp;every element appears three times except for one, which appears exactly once. Find the single element and return it.

You must&nbsp;implement a solution with a linear runtime complexity and use&nbsp;only constant&nbsp;extra space.

&nbsp;
Example 1:
Input: nums = [2,2,3,2]
Output: 3
Example 2:
Input: nums = [0,1,0,1,0,1,99]
Output: 99

&nbsp;
Constraints:


	1 &lt;= nums.length &lt;= 3 * 104
	-231 &lt;= nums[i] &lt;= 231 - 1
	Each element in nums appears exactly three times except for one element which appears once.


import math
class Solution(object):
    def singleNumber(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        [0,-1,1,0]
        
        [2,2,3,2]
        [2,2,3,2]
        [2,2,3,2]
        10   10   11  10
        """
        total = sum(nums)
        
        uniqueTotals = set()
        while nums:
            uniqueTotals.add(nums.pop())
        return (sum(uniqueTotals)*3 - total)/2
class Solution {
    public int singleNumber(int[] nums) {

        int[] bitCount = new int[32]; // 32 bit number

        // Count occurrence of each bits in each num
        for (int i = 0; i < bitCount.length; i++) {
            for (int num : nums) {
                if ((num & 1 << i) != 0) // If ith bit in "num" is 1
                    bitCount[i]++;
            }
        }

        // Check the bit which doesn't have count multiple of 3 (i.e. no of repeating digits in input nums arr)
        // and add it to the result.
        int result = 0;
        for (int i = 0; i < bitCount.length; i++)
            result += (bitCount[i] % 3) * (1 << i);

        return result;
    }
}
class Solution {
public:
    int singleNumber(vector<int>& nums) {
        unordered_map<int,int> mp;
        int ans= 0;
        for(auto i: nums){
            mp[i]++;
        }
        for(auto j: mp){
            if(j.second == 1){
                ans = j.first;
                break;
            }
        }
        return ans;
        
    }
};
 /**
 * @param {number[]} nums
 * @return {number}
 */
var singleNumber = function(nums) {
    if(nums.length === 1) return nums[0];

    const objNums = {};
    for(var indexI=0; indexI<nums.length; indexI++){
       if(objNums[nums[indexI]] === 2) delete objNums[nums[indexI]];
       else objNums[nums[indexI]] = (objNums[nums[indexI]] || 0) + 1;
    }

    return Object.keys(objNums)[0];
};
Single Number II