leetcode191-位1的个数
摘要:
1.循环检查二进制位 把题目给出的数不断对2取余,余数为1则计数 class Solution { public: int hammingWeight(uint32_t n) { int count=0; while(n) { if(n%2==1) count++; //还可以直接化简为count+ 阅读全文
posted @ 2022-09-02 17:56 ᶜʸᵃⁿ 阅读(17) 评论(0) 推荐(0)