class Solution { public String addStrings(String num1, String num2) { StringBuilder res = new StringBuilder(); int carry = 0; int i=num1.length()-1, j = num2.length()-1; while(i>=0 || j>=0|| carry>0){ int x=0, y=0; if(i>=0) x = num1.charAt(i--)-'0'; if(j>=0) y= num2.charAt(j--) -'0'; int sum = x+y+carry; carry= sum/10; sum = sum%10; res.insert(0, (char)(sum+'0')); } return res.toString(); } }