Skip to content

Commit 729bd7f

Browse files
committed
number of 1 bit solution
1 parent 762cfe1 commit 729bd7f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class Solution:
2+
def hammingWeight(self, n: int) -> int:
3+
# n์„ 2์ง„์ˆ˜๋กœ ๋ณ€ํ™˜ํ•œ ๋ฌธ์ž์—ด์—์„œ 1์˜ ๊ฐฏ์ˆ˜๋ฅผ ๋ฐ˜ํ™˜
4+
return len(list(filter(lambda x: x == "1", bin(n)[2:])))

0 commit comments

Comments
ย (0)