标签:return com with appear css color without cto line
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
Example 1: Input: [2,2,3,2] Output: 3 Example 2: Input: [0,1,0,1,0,1,99] Output: 99
code
class Solution { public: int singleNumber(vector<int>& nums) { if(nums.empty()) return -1; else if(nums.size()==1) return nums.front(); int res=0; for(int i=31;i>=0;--i) { int mask=1<<i; int count=0; for(int j=0;j<nums.size();++j) if(mask&nums.at(j)) ++count; if(count%3) res|=mask; } return res; } };
标签:return com with appear css color without cto line
原文地址:https://www.cnblogs.com/tianzeng/p/11074823.html