# 二进制求和

<p>给你两个二进制字符串，返回它们的和（用二进制表示）。</p><p>输入为 <strong>非空 </strong>字符串且只包含数字&nbsp;<code>1</code>&nbsp;和&nbsp;<code>0</code>。</p><p>&nbsp;</p><p><strong>示例&nbsp;1:</strong></p><pre><strong>输入:</strong> a = &quot;11&quot;, b = &quot;1&quot;<strong><br />输出:</strong> &quot;100&quot;</pre><p><strong>示例&nbsp;2:</strong></p><pre><strong>输入:</strong> a = &quot;1010&quot;, b = &quot;1011&quot;<strong><br />输出:</strong> &quot;10101&quot;</pre><p>&nbsp;</p><p><strong>提示：</strong></p><ul>	<li>每个字符串仅由字符 <code>&#39;0&#39;</code> 或 <code>&#39;1&#39;</code> 组成。</li>	<li><code>1 &lt;= a.length, b.length &lt;= 10^4</code></li>	<li>字符串如果不是 <code>&quot;0&quot;</code> ，就都不含前导零。</li></ul>

## template

```python
class Solution(object):
	def addBinary(self, a, b):
		res = ''
		lsa, lsb = len(a), len(b)
		pos, plus, curr = -1, 0, 0
		while (lsa + pos) >= 0 or (lsb + pos) >= 0:
			if (lsa + pos) >= 0:
				curr += int(a[pos])
			if (lsb + pos) >= 0:
				curr += int(b[pos])
			res = str(curr % 2) + res
			curr //= 2
			pos -= 1
		if curr == 1:
			res = '1' + res
		return res
# %%
s = Solution()
print(s.addBinary(a = "1010", b = "1011"))
```

## 答案

```python

```

## 选项

### A

```python

```

### B

```python

```

### C

```python

```