class Solution { public: int hammingWeight(uint32_t n) { int result=0; while(n){ n=n&(n-1); result++; } return result; } };
Number of 1 Bits
原文:http://www.cnblogs.com/qiaomu/p/4469973.html