2022-03-27 20:56:26 +08:00
|
|
|
<p>Given two binary strings <code>a</code> and <code>b</code>, return <em>their sum as a binary string</em>.</p>
|
|
|
|
|
|
|
|
<p> </p>
|
2023-12-09 18:42:21 +08:00
|
|
|
<p><strong class="example">Example 1:</strong></p>
|
2022-03-27 20:56:26 +08:00
|
|
|
<pre><strong>Input:</strong> a = "11", b = "1"
|
|
|
|
<strong>Output:</strong> "100"
|
2023-12-09 18:42:21 +08:00
|
|
|
</pre><p><strong class="example">Example 2:</strong></p>
|
2022-03-27 20:56:26 +08:00
|
|
|
<pre><strong>Input:</strong> a = "1010", b = "1011"
|
|
|
|
<strong>Output:</strong> "10101"
|
|
|
|
</pre>
|
|
|
|
<p> </p>
|
|
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
<li><code>1 <= a.length, b.length <= 10<sup>4</sup></code></li>
|
|
|
|
<li><code>a</code> and <code>b</code> consist only of <code>'0'</code> or <code>'1'</code> characters.</li>
|
|
|
|
<li>Each string does not contain leading zeros except for the zero itself.</li>
|
|
|
|
</ul>
|