Lintcode 408. Add Binary (Easy) (Python)

408. Add Binary

Description:

Given two binary strings, return their sum (also a binary string).
Example
a = 11
b = 1
Return 100

Code:

class Solution:
    """
    @param a: a number
    @param b: a number
    @return: the result
    """
    def addBinary(self, a, b):
        # write your code here
        return bin(int(a,2)+int(b,2))[2:]

猜你喜欢

转载自blog.csdn.net/weixin_41677877/article/details/81214134