Leetcode 137 Solution
This article provides solution to leetcode question 137 (single-number-ii)
Access this page by simply typing in "lcs 137" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/single-number-ii
Solution
class Solution {
public:
int singleNumber(vector<int>& nums) {
int res = 0;
for (int t = 0; t < 32; t++)
{
int sum = 0;
for (int i = 0; i < nums.size(); i++)
{
sum += (nums[i] >> t) & 1;
}
res |= (sum % 3) << t;
}
return res;
}
};