Skip to content

Commit 72f59ed

Browse files
committed
solve : sum of the integers
1 parent 82d9503 commit 72f59ed

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

sum-of-two-integers/samthekorean.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# TC : O(n)
2+
# SC : O(n)
3+
class Solution:
4+
def getSum(self, a: int, b: int) -> int:
5+
6+
mask = 0xFFFFFFFF
7+
8+
while (b & mask) > 0:
9+
10+
carry = (a & b) << 1
11+
a = a ^ b
12+
b = carry
13+
14+
return (a & mask) if b > 0 else a

0 commit comments

Comments
 (0)