@@ -0,0 +1,990 @@
+/***%0A * Given two binary strings, return their sum (also a binary string).%0A *%0A * For example,%0A * a = %2211%22%0A * b = %221%22%0A * Return %22100%22.%0A */%0A%0Aimport java.util.StringBuffer;%0A%0Apublic class Solution %7B%0A    public String addBinary(String a, String b) %7B%0A        StringBuffer ret = new StringBuffer();%0A        int an = a.length();%0A        int bn = b.length();%0A        int n = an %3E bn? an : bn;%0A        int addup = 0;%0A        int sum = 0;%0A        for (int i = 1; i %3C= n; i++) %7B%0A            if (an - i %3E= 0 && bn - i %3E= 0) %7B%0A                sum = a.charAt(an - i) - '0' + b.charAt(bn - i) -'0' + addup;%0A            %7D else if (an - i %3C 0) %7B%0A                sum = b.charAt(bn - i) - '0'+ addup;%0A%0A            %7D else if (bn - i %3C 0) %7B%0A                sum = a.charAt(an - i) - '0' + addup;%0A            %7D%0A            ret.append(sum %25 2 == 0 ? '0' : '1');%0A            addup = sum / 2 == 1? 1 : 0;%0A        %7D%0A        if (addup == 1)%0A            ret.append('1');%0A        return ret.reverse().toString();%0A    %7D%0A%7D%0A

add AddBinary.java