Given two binary strings a and b, return their sum as a binary string.
F(0) = 0, F(1) = 1
F(n) = F(n - 1) + F(n - 2), for n > 1.
Input: a = "11", b = "1"
Output: "100"
Input: a = "1010", b = "1011"
Output: "10101"
/**
* @param {string} a
* @param {string} b
* @return {string}
*/
let addBinary = function(a, b) {
let i=a.length-1;
let j=b.length-1;
let carrige=0;
let sum='';
for(; i>=0 || j>=0; ){
let subSum=carrige;
if(i>=0){
subSum=subSum+(a[i] -'0');
i--;
}
if(j>=0){
subSum=subSum+(b[j]-'0');
j--;
}
if(subSum>1){
carrige=1;
subSum=subSum%2;
}
else{
carrige=0;
}
sum=subSum+sum;
}
if(carrige>0){
sum='1'+sum;
}
return sum;
};
~.~