标签:
class Solution { public: int NumberOf1(int n) { bitset<32> bit(n); return bit.count(); } };
class Solution { public: int NumberOf1(int n) { int count = 0; while(n!= 0){ count++; n = n & (n - 1); } return count; } };
标签:
原文地址:http://www.cnblogs.com/xuyan505/p/5354759.html