1class Solution {2public int singleNumber(int[] nums) {34int[] bitCount = new int[32]; // 32 bit number56// Count occurrence of each bits in each num7for (int i = 0; i < bitCount.length; i++) {8for (int num : nums) {9if ((num & 1 << i) != 0) // If ith bit in "num" is 110bitCount[i]++;11}12}1314// Check the bit which doesn't have count multiple of 3 (i.e. no of repeating digits in input15// nums arr)16// and add it to the result.17int result = 0;18for (int i = 0; i < bitCount.length; i++) result += (bitCount[i] % 3) * (1 << i);1920return result;21}22}