@@ -0,0 +1,1089 @@
+package me.wayne.leetcodetop100;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0A/**%0A * %E7%BB%99%E4%BD%A0%E4%B8%80%E4%B8%AA%E6%95%B4%E6%95%B0 n %EF%BC%8C%E5%AF%B9%E4%BA%8E 0 %3C= i %3C= n %E4%B8%AD%E7%9A%84%E6%AF%8F%E4%B8%AA i %EF%BC%8C%E8%AE%A1%E7%AE%97%E5%85%B6%E4%BA%8C%E8%BF%9B%E5%88%B6%E8%A1%A8%E7%A4%BA%E4%B8%AD 1 %E7%9A%84%E4%B8%AA%E6%95%B0 %EF%BC%8C%0A * %E8%BF%94%E5%9B%9E%E4%B8%80%E4%B8%AA%E9%95%BF%E5%BA%A6%E4%B8%BA n + 1 %E7%9A%84%E6%95%B0%E7%BB%84 ans %E4%BD%9C%E4%B8%BA%E7%AD%94%E6%A1%88%E3%80%82%0A * %3Cp%3E%0A * https://leetcode-cn.com/problems/counting-bits/%0A */%0Apublic class LC338_CountBits %7B%0A%0A    public int%5B%5D countBits(int n) %7B%0A        int%5B%5D res = new int%5Bn + 1%5D;%0A        Arrays.fill(res, 0);%0A%0A        List%3CInteger%3E targetList = getTargetList(n);%0A        for (int i = 0; i %3C= n; i++) %7B%0A            for (Integer target : targetList) %7B%0A                if ((i & target) == target) %7B%0A                    int value = res%5Bi%5D;%0A                    res%5Bi%5D = ++value;%0A                %7D%0A            %7D%0A        %7D%0A        return res;%0A    %7D%0A%0A    /**%0A     * %E6%B1%82%E5%87%BA%E6%AF%94n%E5%B0%8F%E7%9A%84%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%AF%94%E8%BE%83%E4%BD%8D%E7%9A%84%E5%88%97%E8%A1%A8%0A     * %E5%A6%82n=17%E6%97%B6%EF%BC%8C%E5%88%97%E8%A1%A8%E4%B8%AD%E6%9C%891%E3%80%812%E3%80%814%E3%80%818%E3%80%8116%0A     */%0A    private List%3CInteger%3E getTargetList(int n) %7B%0A        List%3CInteger%3E targetList = new ArrayList%3C%3E();%0A        int target = 0;%0A        while (Math.pow(2, target) %3C= n) %7B%0A            targetList.add((int) Math.pow(2, target));%0A            target++;%0A        %7D%0A        return targetList;%0A    %7D%0A%7D%0A

add LC338_CountBits