We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent da1edfd commit 428ea42Copy full SHA for 428ea42
Swift/338. Counting Bits.swift
@@ -0,0 +1,11 @@
1
+// 338. Counting Bits
2
+// 28ms
3
+func countBits(_ num: Int) -> [Int] {
4
+ var arr = Array(repeating: 0, count: num+1), i = 0
5
+ while i <= num {
6
+ arr[i] = i.nonzeroBitCount
7
+ i += 1
8
+ }
9
+
10
+ return arr
11
+}
0 commit comments