Skip to content

Commit a048c17

Browse files
committed
Solution Number of 1 bits
1 parent e62a0af commit a048c17

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

number-of-1-bits/doitduri.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Solution {
2+
func hammingWeight(_ n: Int) -> Int {
3+
let bitString = String(n, radix: 2)
4+
return bitString.filter { $0 == "1" }.count
5+
}
6+
}

0 commit comments

Comments
 (0)