67. Add Binary

Given two binary strings, return their sum (also a binary string).

The input strings are both non-empty and contains only characters 1 or 0.

class Solution(object):
    def addBinary(self, a, b):
        """
:type a: str :type b: str :rtype: str """ out = int(a, 2) + int(b,2) return bin(out)[2:]

 

以上

posted on 2018-09-11 10:33  jydd  阅读(64)  评论(0编辑  收藏  举报

导航