题目:难度(Easy)

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

For example, 

a = “11” 
b = “1” 
Return “100”.


TagsString

分析:本题是将两个二位制string格式的数相加,再以string格式输出

          第一次接触需要转化进位制的题目

思路:注意int,str的格式之间的转化,str+str,int+int代表不同的意义。

          将数值转化为十位制int后,相加,再转化为二位制,再转化为str

          所用函数: int(a,2)------将表示二进制的string a 转化为十进制的整数

                            bin(n)------将十进制整数转化为二进制的字符串

                            bin('11')-------- ob100(转化的字符串会有ob的前缀)leetcode67-Add Binary

相关文章:

  • 2021-06-28
  • 2021-11-12
  • 2022-01-01
  • 2021-11-27
猜你喜欢
  • 2022-12-23
  • 2021-11-12
相关资源
相似解决方案