[leetcode][67] Add Binary

来源:互联网 发布:domori巧克力知乎 编辑:程序博客网 时间:2024/06/06 01:12

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

For example,
a = "11"
b = "1"

Return "100".


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


0 0
原创粉丝点击