<p>Given two binary strings <code>a</code> and <code>b</code>, return <em>their sum as a binary string</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> a = "11", b = "1"
<strong>Output:</strong> "100"
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> a = "1010", b = "1011"
<strong>Output:</strong> "10101"
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= a.length, b.length &lt;= 10<sup>4</sup></code></li>
	<li><code>a</code> and <code>b</code> consist&nbsp;only of <code>&#39;0&#39;</code> or <code>&#39;1&#39;</code> characters.</li>
	<li>Each string does not contain leading zeros except for the zero itself.</li>
</ul>

class Solution:
    def addBinary(self, a: str, b: str) -> str:
        if (len(a)!= len(b)):
            diff=len(a)-len(b)

            if diff<0:
                a=str("0"*abs(diff))+a
            else:
                b=str("0"*abs(diff))+b
        carry=0
        ans=[]
        print(a)
        print(b)
        for i in range(len(a)-1,-1,-1):

            bit_a = int(a[i])
            bit_b = int(b[i])
            temp = bit_a + bit_b + carry
            if temp == 0:
                ans.append('0')
                carry = 0
            elif temp == 1:
                ans.append('1')
                carry = 0
            elif temp == 2:
                ans.append('0')
                carry = 1
            elif temp == 3:
                ans.append('1')
                carry = 1
        if carry:
            ans.append('1')
        s = "".join(ans)

        return s[::-1]
16500