码迷,mamicode.com
首页 > 其他好文 > 详细

14.leetcode67_add_binary

时间:2018-02-07 00:40:35      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:bsp   mat   div   pos   int   描述   body   return   code   

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

 

14.leetcode67_add_binary

标签:bsp   mat   div   pos   int   描述   body   return   code   

原文地址:https://www.cnblogs.com/19991201xiao/p/8424676.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!