力扣题目链接
位运算
class Solution {
public int[] countBits(int n) {
int[] nums = new int[n+1];
for(int i=0;i<=n;++i){
for(int j=0;j<32;++j){
nums[i] += (i>>j) &1;
}
}
return nums;
}
}
标签:countBits,return,nums,二进制,offer,个数,int
来源: https://www.cnblogs.com/jianjiana/p/15861670.html