Given two binary strings a and b, return their sum as a binary string.

&nbsp;
Example 1:
Input: a = "11", b = "1"
Output: "100"
Example 2:
Input: a = "1010", b = "1011"
Output: "10101"

&nbsp;
Constraints:


	1 &lt;= a.length, b.length &lt;= 104
	a and b consist&nbsp;only of '0' or '1' characters.
	Each string does not contain leading zeros except for the zero itself.


class Solution(object):
    def addBinary(self, a, b):
        """
        :type a: str
        :type b: str
        :rtype: str
        """

        return str(bin(int(a, base = 2)+int(b, base = 2)))[2:]
class Solution {
    public String addBinary(String a, String b) {
        StringBuilder sb = new StringBuilder();
        int carry = 0;
        int i= a.length() -1;
        int j= b.length() -1;
        while(i>=0 || j>=0){
            int sum = carry;
            if(i>=0)
                sum+=a.charAt(i--)-'0'; // -'0' is just to convert char in integer
            if(j>=0)
                sum+=b.charAt(j--)-'0';
            sb.append(sum%2);   // If we have sum = 1  1  then = 2 % 2 = 0 and 0  1 = 1 % 2 = 1
            carry = sum /2;
        }
        if(carry>0)
            sb.append(carry);
        return sb.reverse().toString();
    }
}
class Solution {
public:
    string addBinary(string a, string b) {
        string ans;
        int i=a.length()-1,j=b.length()-1;
        int carry=0;
        while(carry||i>=0||j>=0){
            if(i>=0){
                carry+=a[i]-'0';
                i--;
            }
            if(j>=0){
                carry+=b[j]-'0';
                j--;
            }
            ans+=carry%2+'0';
            carry=carry/2;
        }
        reverse(ans.begin(),ans.end());
        return ans;
    }
};
var addBinary = function(a, b) {
    let i = a.length-1, j = b.length-1, carry = 0
    let s =[]
    while(i >= 0 || j >= 0){
        let sum = carry
        if(i >= 0)  sum += a[i--].charCodeAt() - 48
        if(j >= 0)  sum += b[j--].charCodeAt() - 48
        s.unshift(sum % 2)
        carry = ~~(sum/2)
    }
    return carry > 0 ? "1" + s.join("") : s.join("")
};
Add Binary