做太多遍了,秒杀。
class Solution {public: int hammingWeight(uint32_t n) { int num = 0; for(;n; n &=(n-1), num++); return num; }};
本文共 202 字,大约阅读时间需要 1 分钟。
做太多遍了,秒杀。
class Solution {public: int hammingWeight(uint32_t n) { int num = 0; for(;n; n &=(n-1), num++); return num; }};
转载于:https://www.cnblogs.com/dplearning/p/4344854.html