# Add Binary (Leetcode 67)

Problem Link: <https://leetcode.com/problems/add-binary/>

```python
class Solution:
    def addBinary(self, a: str, b: str) -> str:
        
        ans=''
        carry=0
        n1=len(a)
        n2=len(b)
        i=n1-1
        j=n2-1
        while(i>=0 and j>=0):
            digit1=int(a[i])
            digit2=int(b[j])
            summ=digit1+digit2+carry
            ans=str(summ%2)+ans
            carry=summ//2
            i-=1
            j-=1
        
        while(i>=0):
            digit1=int(a[i])
            summ=digit1+carry
            ans=str(summ%2)+ans
            carry=summ//2
            i-=1
        
        while(j>=0):
            digit1=int(b[j])
            summ=digit1+carry
            ans=str(summ%2)+ans
            carry=summ//2
            j-=1
        
        if(carry==1):
            ans='1'+ans
        
        return ans 
```
