乐趣区

关于leetcode:338-Counting-Bits比特位计数

class Solution {public int[] countBits(int num) {int[] dp = new int[num+1];
        dp[0] = 0;
        for(int i = 1; i <= num; i++) {dp[i] = dp[i/2] + i%2;
        }
        return dp;
    }
}
退出移动版