Skip to content

Commit c8d2130

Browse files
committed
edited : number of 1 bits
1 parent 85bea7c commit c8d2130

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

number-of-1-bits/ayleeee.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
시간 복잡도는 비트 길이에 비례함
77
88
O(1) => 추가 메모리 사용 없이 상수 공간만 사용
9+
10+
Runtime 0ms
11+
Memory 17.71mb
912
'''
1013

1114
def hammingWeight(self, n: int) -> int:
1215
count = 0
1316
while n :
1417
count +=n & 1
1518
n >>= 1
16-
return count
19+
return count

0 commit comments

Comments
 (0)