We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9254515 commit f50e6f5Copy full SHA for f50e6f5
easy/sqrtx.test.ts
@@ -1,13 +1,7 @@
1
// Problem: https://leetcode.com/problems/sqrtx/description/
2
-// Doc: https://leetcode.com/problems/sqrtx/solutions/5491801/efficient-binary-search-for-square-root-calculation/
+// Doc: https://leetcode.com/problems/sqrtx/solutions/5491842/efficient-binary-search-for-calculating-square-root/
3
const mySqrt = (x: number): number => {
4
- let [l, r] = [0, 1];
5
- // We are not allowed to use Math.pow
6
- // So we initialize r using this loop :v
7
- for (let i = 1; i <= 31; i++) {
8
- r *= i;
9
- }
10
- r--;
+ let [l, r] = [0, x];
11
12
let ans = 0;
13
while (l <= r) {
0 commit comments