标签:
// An easy recurrence for this problem is f[i] = f[i / 2] + i % 2. /* * 338. Counting Bits * 2016-7-10 by Mingyang */ public int[] countBits(int num) { int[] f = new int[num + 1]; for (int i = 1; i <= num; i++) f[i] = f[i >> 1] + (i & 1); return f; }
标签:
原文地址:http://www.cnblogs.com/zmyvszk/p/5659086.html