14.leetcode67_add_binary

1.题目描述

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

做二进制加法

2.题目分析

这个题偷懒了,直接进行了进制转换

3.解题思路

 1 class Solution(object):
 2     def addBinary(self, a, b):
 3         """
 4         :type a: str
 5         :type b: str
 6         :rtype: str
 7         """
 8         a1=int(a,2)
 9         b1=int(b,2)
10         s=a1+b1
11         s='{0:b}'.format(s)
12         return s

 

posted @ 2018-02-06 23:09  vlice  阅读(71)  评论(0编辑  收藏  举报