Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/neetcode-gh/leetcode
/ add
Method
add
python/0371-sum-of-two-integers.py:3–6 ·
view source on GitHub ↗
(a, b)
Source
from the content-addressed store, hash-verified
1
class
Solution:
2
def
getSum(self, a: int, b: int) -> int:
3
def
add(a, b):
4
if
not a or not b:
5
return
a or b
6
return
add(a ^ b, (a & b) << 1)
7
8
if
a * b < 0:
# assume a < 0, b > 0
9
if
a > 0:
Callers
nothing calls this directly
Calls
1
add
Function · 0.50
Tested by
no test coverage detected