1. Add numbers: definitely go in the REVERSE order;
  2. for(A;B;C): satisfying A and B: go into for; then execute C.
  3. carry > 0 inside for: when carry == 0 and i<0, j<0: no need going into for loop;
1
2
3
4
5
6
7
8
9
10
11
public String addStrings(String num1, String num2) {
StringBuilder sb = new StringBuilder();
int carry = 0;
for (int i = num1.length() -1, j = num2.length() -1; i >= 0 || j >= 0 || carry > 0; --i, --j) {
int x = i >= 0 ? num1.charAt(i) - '0' : 0;
int y = j >= 0 ? num2.charAt(j) - '0' : 0;
sb.append((x + y + carry) % 10);
carry = ((x + y + carry) / 10);
}
return sb.reverse().toString();
}