Skip to content

Commit d459373

Browse files
committed
feat: solve 3
1 parent 43213a1 commit d459373

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

number-of-1-bits/devyulbae.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1+
"""
2+
Blind75 - Number of 1 Bits
3+
https://leetcode.com/problems/number-of-1-bits/
4+
시간복잡도 : O(log n)
5+
공간복잡도 : O(1)
6+
7+
풀이 :
8+
파이썬의 내장함수 bin() -> O(log n)
9+
문자열 메서드 count() -> O(log n)
10+
11+
"""
12+
113
class Solution:
214
def hammingWeight(self, n: int) -> int:
3-
15+
return str(bin(n)).count('1')
16+
417

0 commit comments

Comments
 (0)