您的位置:首页 > 编程语言 > Python开发

<LeetCode><Easy> 67 Add Binary

2015-10-17 18:54 706 查看
Given two binary strings, return their sum (also a binary string).

For example,

a = 
"11"


b = 
"1"


Return 
"100"
.

#Python2   48ms

class Solution(object):
def addBinary(self, a, b):
"""
:type a: str
:type b: str
:rtype: str
"""
return bin(int(a,2)+int(b,2))[2:]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  leetcode python