// class Solution { // public int[] countBits(int n) { // ArrayList<Integer> list = new ArrayList<>(); // // 将0-n每一个数字首先转换为二进制数,存放于list中 // for (int i = 0; i <= n; i++) { // String str = Integer.toBinaryString(i); // int ans = Integer.parseInt(str, 2); // list.add(ans); // }
// return count(list);
// } // // 计数函数 // public int[] count(ArrayList<Integer> list) { // int[] res = new int[list.size()]; // res[0] = 0; // res[1] = 1; // int count = 0; // int size = res.length;
// for (int i = 0; i < size; i++) { // int a = list.get(i); // int b = list.get(i);