leetcode 二进制求和 python

Posted September·

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode 二进制求和 python相关的知识,希望对你有一定的参考价值。

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


i = Solution()

print(i.addBinary(‘1010‘, ‘1011‘))  

以上是关于leetcode 二进制求和 python的主要内容,如果未能解决你的问题,请参考以下文章