You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An easy solution for Single number I and II is based on 32 bit presentation which python do not naturally support. Is there a way to transform this to python? Thanks
class Solution {
public:
int singleNumber(vector& nums) {
int digits[32]={0};
for( int k=0;k<nums.size();k++)
for ( int i =0;i<32;i++)
if ( nums[k]>>i&1)
digits[i]+=1;
int res=0;
for ( int i =0;i<32;i++)
res+=(digits[i]%2)<<i;
return res;
}
};
The text was updated successfully, but these errors were encountered:
An easy solution for Single number I and II is based on 32 bit presentation which python do not naturally support. Is there a way to transform this to python? Thanks
class Solution {
public:
int singleNumber(vector& nums) {
int digits[32]={0};
for( int k=0;k<nums.size();k++)
for ( int i =0;i<32;i++)
if ( nums[k]>>i&1)
digits[i]+=1;
int res=0;
for ( int i =0;i<32;i++)
res+=(digits[i]%2)<<i;
return res;
}
};
The text was updated successfully, but these errors were encountered: