diff --git a/Leetcode/Counting_Bits#55.java b/Leetcode/Counting_Bits#55.java new file mode 100644 index 0000000..cb0d3a6 --- /dev/null +++ b/Leetcode/Counting_Bits#55.java @@ -0,0 +1,8 @@ +class Solution { + public int[] countBits(int n) { + int a[] = new int[n+1]; + for(int i=1;i<=n;i++) + a[i] = a[i>>1] + i%2; + return a; + } +}