[leetcode][67] Add Binary

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:]
        


全部评论

相关推荐

10-03 17:08
已编辑
西安电子科技大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务