Given two binary strings, return their sum (also a binary string).
The input strings are both non-empty and contains only characters
1
or0
.
Constraints:
- Each string consists only of
'0'
or'1'
characters.1 <= a.length
,b.length <= 10^4
- Each string is either
"0"
or doesn't contain any leading zero.
給予兩個二進制字串,回傳他們的總和(也是一個二進制字串)。
輸入字串都不會是空的並且只包含
1
或0
。
限制:
- 每個字串只包含
0
或1
的字元。1 <= a.length
,b.length <= 10^4
- 每個字串除了
"0"
以外,不會有零在最前面的情況。
string
,因此取單個位元是char
而不是int
。0
在最前面才可以正常執行。LeetCode
C++