标签:tor single enum turn color bsp amp span for
class Solution { public: int singleNumber(vector<int>& nums) { int res = 0; for(int i=0;i < 32;i++){ int sum = 0; for(int num:nums){ sum += (num>>i)&1; //所有数字二进制第一位有1的加 } res = res|((sum%3)<<i);//有1的3个 一取模没了,留下 1个的,往左移i位用”或“赋值 } return res; } };
标签:tor single enum turn color bsp amp span for
原文地址:https://www.cnblogs.com/cunyusup/p/10556204.html