File tree Expand file tree Collapse file tree 5 files changed +10
-0
lines changed Expand file tree Collapse file tree 5 files changed +10
-0
lines changed Original file line number Diff line number Diff line change
1
+ # TC: O(n), SC: O(n)
2
+
1
3
class Solution :
2
4
def countBits (self , n : int ) -> List [int ]:
3
5
answer = []
Original file line number Diff line number Diff line change
1
+ # TC: O(n), SC: O(n)
2
+
1
3
from collections import defaultdict
2
4
3
5
class Solution :
Original file line number Diff line number Diff line change
1
+ # TC: O(n), SC: O(1)
2
+
1
3
class Solution :
2
4
def missingNumber (self , nums : List [int ]) -> int :
3
5
for i in range (len (nums )+ 1 ):
Original file line number Diff line number Diff line change
1
+ # TC: O(1), SC: O(1)
2
+
1
3
class Solution :
2
4
def hammingWeight (self , n : int ) -> int :
3
5
return bin (n ).count ("1" )
Original file line number Diff line number Diff line change
1
+ # TC: O(1), SC: O(1)
2
+
1
3
class Solution :
2
4
def reverseBits (self , n : int ) -> int :
3
5
return int (f"{ bin (n )[2 :]:0>32} " [::- 1 ], 2 )
You can’t perform that action at this time.
0 commit comments