90ms
public class Solution { public String solve (String s, String t) { char[] char1 = s.toCharArray(); char[] char2 = t.toCharArray(); int i = char1.length-1; int j = char2.length-1; //carry表进位 int carry = 0; StringBuffer ans = new StringBuffer(); while (i >= 0 || j >= 0 || carry != 0) { int a = 0; int b = 0; if(i >= 0) { a = char1[i] - '0'; i--; } if (j >= 0) { b = char2[j] - '0'; j--; } int sum = a + b + carry; int rem = sum % 10; carry = sum / 10; ans.append(rem); } StringBuffer res = ans.reverse(); return new String(res); } }