67. Add Binary
problem description
Given two binary strings, return their sum (also a binary string).
The input strings are both non-empty and contains only characters 1
or 0
.
Example 1:
Example 2:
algorithm thought
和十进制加法没什么不同,都是定义一个进位标志位,两数相加再加上标志位。得到的结果就是这一位,改变标志位。最后注意开头的0需要删除
code
algorithm analysis
线性处理两个字符串,最后时间复杂度O(n)
Last updated