/**
 * 
 */
package com.wangsus.codetest.difficulty2;

/**
 * @author Su
 *
 *Given two binary strings, return their sum (also a binary string).

For example,
a = "11"
b = "1"
Return "100".
 */
public class Add_Binary {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}
	public class Solution {
	    public String addBinary(String a, String b) {
	        return "";
	    }
	}
}

@@ -288,43 +288,128 @@
 %7B%0A%09%09
-// TODO Auto-generated method stub%0A
+String thisA = %220%22;%0A%09%09String thisB = %221%22;%0A%09%09Solution s = new Solution();%0A%09%09System.out.println(s.addBinary(thisA,thisB));
 %0A%09%7D%0A
@@ -412,24 +412,31 @@
 %0A%09%7D%0A%09public 
+static 
 class Soluti
@@ -500,22 +500,1249 @@
     
-    return %22%22;
+%09//need ask the length , need consider overflow. seems cannot convert to int for extra long string.%0A%09    %09long aa = 0;%0A%09    %09long bb = 0;%0A%09    %09try%7B%0A%09    %09%09aa = Long.parseLong(a);%09    %09%09%0A%09    %09%7Dcatch(Exception e)%7B%09    %09%09%0A//%09    %09%09System.out.println(%22Something Wrong.%22);%0A%09    %09%7D%0A%09    %09try%7B%0A%09    %09%09bb = Long.parseLong(b);%0A%09    %09%7Dcatch(Exception e)%7B%0A//%09    %09%09System.out.println(%22Something Wrong.%22);%0A%09    %09%7D%0A%09    %09long total = aa+bb;%0A%09    %09System.out.println(%22aa:%22+aa+%22:bb:%22+bb+%22:total:%22+total);%0A%09    %09String totalStr = %22%22+total;%0A%09    %09boolean up = false;%0A%09    %09StringBuilder sb = new StringBuilder();%0A%09    %09sb.append(totalStr);%0A%09    %09//remember string is from left to right, int is reverse.%0A%09    %09for(int i=sb.length()-1;i%3E=0;i--)%7B%0A%09    %09%09if(up)%7B%0A%09%09    %09%09if(sb.charAt(i)=='0')%7B%0A%09%09    %09%09%09sb.setCharAt(i, '1');%0A%09%09    %09%09%09up = false;%0A%09%09    %09%09%7Delse if(sb.charAt(i)=='1')%7B%0A%09%09    %09%09%09sb.setCharAt(i, '0');%0A%09%09    %09%09%09up = true;%0A%09%09    %09%09%7Delse if(sb.charAt(i)=='2')%7B%0A%09%09    %09%09%09sb.setCharAt(i, '1');%0A%09%09    %09%09%09up = true;%0A%09%09    %09%09%7D%0A%09    %09%09%7Delse%7B%0A%09    %09%09%09if(sb.charAt(i)=='2')%7B%0A%09%09    %09%09%09sb.setCharAt(i, '0');%0A%09%09    %09%09%09up = true;%0A%09%09    %09%09%7D%0A%09    %09%09%7D%0A%09    %09%7D%0A%09    %09if(up)%7B%0A%09    %09%09return %221%22+sb.toString();%0A%09    %09%7Delse%7B%0A%09    %09%09return sb.toString();%0A%09    %09%7D%09        
 %0A%09  

Add_Binary Fail