We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * 计算两个数之和 * @param s string字符串 表示第一个整数 * @param t string字符串 表示第二个整数 * @return string字符串 */ function solve( s , t ) { let add = 0; let i = s.length - 1; let j = t.length - 1; let stack = []; while(i > -1 && j > -1){ let st = (s[i] - 0) + (t[j] - 0) + add; stack.push(st % 10); add = st - 0 > 9? 1: 0; i--; j--; } while(i > -1){ let tmp = (s[i] - 0) + (add - 0); stack.push(tmp % 10); add = tmp - 0 > 9? 1: 0; i--; } while(j > -1){ let tmp = (t[j] - 0) + (add - 0); stack.push(tmp % 10); add = tmp - 0 > 9? 1: 0; j--; } if(add){ stack.push(add); } let result = ""; while(stack.length){ result += stack.pop(); } return result; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: