``c++
Given two binary strings, return their sum (also a binary string).
For example,
a = “11”
b = “1”
Return “100”.
```c++
class Solution {
public:
string addBinary(string a, string b) {
const int lena = a.length();
const int lenb = b.length();
string res;
char ch = 0;
int i = lena - 1, j = lenb - 1;
while(i >= 0 || j >= 0 || ch == 1) {
ch += i >= 0 ? a[i--] - '0' : 0;
ch += j >= 0 ? b[j--] - '0' : 0;
res = (char)(ch % 2 + '0') + res;
ch >>= 1;
}
return res;
}
};