Given a non-negative integer x, return the square root of x rounded down to the nearest integer.
x
You may not use any built-in exponent or square-root function.
x = 4
2
x = 8
Why
sqrt(8) = 2.828…, truncated to 2.
0 <= x <= 2^31 - 1
Topics
Implement mySqrt in the editor and return the answer — printing it is never graded.
mySqrt
Problem 31 of 1146 in the arena