class Solution {
public String addBinary(String a, String b) {
if(a.length() < b.length()){
return addBinary(b,a);
}
int L = Math.max(a.length(),b.length());
StringBuilder toolman = new StringBuilder();
int nafla = 0;
int j = b.length()-1;
for(int i=L-1;i>-1;i--){
if(a.charAt(i) == '1') ++nafla;
if(j > -1 && b.charAt(j--) == '1'){
++nafla;
}
if(nafla % 2 == 1){
toolman.append('1');
}else{
toolman.append('0');
}
nafla /= 2;
}
if(nafla == 1){
toolman.append('1');
}
toolman.reverse();
return toolman.toString();
}
}