标签:tps count esc href class == log span int
public class Solution { public int[] CountBits(int num) { var ary = new int[num + 1]; for (int i = 0; i <= num; i++) { var count = 0; var cur = i; do { var c = cur % 2; if (c == 1) { count++; } cur = cur / 2; } while (cur != 0); ary[i] = count; } return ary; } }
https://leetcode.com/problems/counting-bits/#/description
标签:tps count esc href class == log span int
原文地址:http://www.cnblogs.com/asenyang/p/6786561.html