short but slow python solution


  • 0
    Z
    class Solution(object):
        def addBinary(self, a, b):
            sum=int(a)+int(b)
            for i in range(1,len(str(sum))+1):
                if int(str(sum)[-i])>=2:
                    sum-=2*(10**(i-1))
                    sum+=10**i
            return str(sum)
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.