public String addBinaryStrings(String a, String b) {
        char aChars[]=a.toCharArray();
        char bChars[]=b.toCharArray();
        StringBuilder sb = new StringBuilder();

        int i=aChars.length-1;
        int j=bChars.length-1;
        int carry = 0;

        while(i>=0 || j>=0 || carry==1){

            // get char and decrement
            int aVal=0;
            if (i>=0)
                aVal=(int)(aChars[i--]-'0');
            int bVal=0;
            if (j>=0)
                bVal=(int)(bChars[j--]-'0');

            // sum and handle cases
            int sum = aVal+bVal+carry;
            if (sum==0){
                sb.insert(0,'0');
            }
            else if (sum==1){
                sb.insert(0,'1');
                carry=0;
            }
            else if (sum==2){
                sb.insert(0,'0');
                carry=1;
            }
            else if (sum==3){
                sb.insert(0,'1');
                carry=1;
            }
        }

        return sb.toString();
    }