Skip to content

Commit 847e510

Browse files
committed
feat: add counting bits solution
1 parent 727b537 commit 847e510

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

counting-bits/mangodm-web.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
def countBits(self, n: int) -> List[int]:
6+
answer = [0]
7+
8+
for i in range(1, n + 1):
9+
answer.append(answer[i // 2] + i % 2)
10+
11+
return answer

0 commit comments

Comments
 (0)