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
7. 整数反转
function reverse(x: number): number { let res = 0; while (x !== 0) { // 整数部分 const digit = x % 10; // 每一次都在上一次的基础上乘10 res = res * 10 + digit; // 除数取整 x = Math.trunc(x / 10); // 超出范围的判断 if (res < Math.pow(-2, 31) || res > Math.pow(2, 31) - 1) return 0; } return res; };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
7. 整数反转
The text was updated successfully, but these errors were encountered: