Easiest solution bu using sum approach


#1

Comment body goes here.
if (a.isEmpty()) return b;
if (b.isEmpty()) return a;
StringBuilder result=new StringBuilder();
//calculate the length

//traverse from the end  in both the string
   //for result 
    int i=a.length()-1;
    int j=b.length()-1;
    int digit1=0;
    int digit2=0;
    int carry=0;
   
    while(i>=0 || j>=0 || carry>0)
    {
        //if one string length has not been ended
        if(i>=0)
        {
             digit1=a.charAt(i)-'0';
        }
        //otherwise it its set to zero
        else
        {
            digit1=0;
            
        }
        
        if(j>=0)
        {
             digit2=b.charAt(j)-'0';
        }
        else
        {
            digit2=0;
            
        }
          int  sum = digit1 + digit2 + carry;
        
         if (sum == 3) result.append(1); // 11
        else if (sum == 2) result.append(0); //10
        else if (sum == 1) result.append(1); // 01
        else result.append(0); // 00
        
        carry = sum >= 2 ? 1 : 0;
        i--;
        j--;
    }
    return result.reverse().toString();