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
69. x 的平方根
/** * @param {number} x * @return {number} */ var mySqrt = function (x) { // 注意题目只需要返回整数部分 // 找到中间节点 let left = 0; let right = Math.trunc(x / 2); while (left <= right) { const rightValue = right * right; if (rightValue === x) return right; if (rightValue > x) { right = Math.trunc(right / 2); } else { left = right; right = right + 1 if (left * left < x && right * right > x) return left; } } };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
69. x 的平方根
The text was updated successfully, but these errors were encountered: