Skip to content

Instantly share code, notes, and snippets.

@makeapp007
Created January 10, 2022 21:38
Show Gist options
  • Save makeapp007/039c1d16f985705df5e6ef03dbdb277c to your computer and use it in GitHub Desktop.
Save makeapp007/039c1d16f985705df5e6ef03dbdb277c to your computer and use it in GitHub Desktop.
67. Add Binary
class Solution:
def addBinary(self, a: str, b: str) -> str:
m, n = int(a, 2), int(b, 2)
while n:
ans = m ^ n
carry = (m & n) << 1
m = ans
n = carry
return bin(m)[2:]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment