public String solve (String s, String t) { if (s==null || t==null) return null; // write code here int i = s.length()-1; int j = t.length()-1; int jw=0; Stack<Integer> stack=new Stack<>(); while (i>=0 && j>=0){ int si = Integer.parseInt(s.charAt(i)+""); int sj = Integer.parseInt(t.charAt(j)+""); int zh = si+sj+jw; jw = zh/10; int res = zh%10; stack.add(res); i--; j--; } //i s stack jw = zz(i,s,stack,jw); jw = zz(j,t,stack,jw); if (jw>0) stack.add(jw); StringBuilder sb = new StringBuilder(); while (stack.size()>0){ sb.append(stack.pop()); } return sb.toString(); } public int zz(int i,String s,Stack<Integer> stack,int jw){ while (i>=0){ int si = Integer.parseInt(s.charAt(i)+""); int zh = si+jw; stack.add(zh%10); jw = zh/10; i--; } return jw; }