@@ -0,0 +1,1172 @@
+/*%0A Given two binary strings, return their sum (also a binary string).%0A%0AFor example,%0Aa = %2211%22%0Ab = %221%22%0AReturn %22100%22. %0A*/%0A%0Aimport java.util.*;%0A%0Apublic class AddBinary %7B%0A%09public static String addBinary(String a, String b) %7B%0A        StringBuilder sb = new StringBuilder();%0A        int M = a.length();%0A        int N = b.length();%0A        int i = M-1;%0A        int j = N-1;%0A        int adds = 0;%0A        while(i %3E= 0 %7C%7C j %3E= 0)%7B%0A            int o1 = 0;%0A            int o2 = 0;%0A            if(i %3E= 0)%7B%0A                o1 = a.charAt(i) - '0';%0A                i--;%0A            %7D%0A            if(j %3E= 0)%7B%0A                o2 = b.charAt(j) - '0';%0A                j--;%0A            %7D%0A            int sum = o1+o2+adds;%0A            sb.append(sum%252);%0A            adds = sum/2;%0A            %0A        %7D%0A        if(adds == 1)%7B%0A            sb.append(1);%0A        %7D%0A        %0A        return sb.reverse().toString();%0A    %7D%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09String p = %2210111%22;%0A%09%09String s = %22101%22;%0A        String res = addBinary(p, s);%0A        System.out.println(%22String 1: %22 + p);%0A        System.out.println(%22String 2: %22 + s);%0A        System.out.println(%22Result: %22 + res);%0A%09%09return;%0A%09%7D%09%0A%7D%0A

add binary-normal