← All problems
Sqrt(x) without built-ins
Compute the integer square root of a non-negative integer x: the largest integer r such that r*r <= x. Do not use built-in exponent or root functions; x can be up to 2^31 - 1, so watch for overflow.
Complexity
Time O(log x), Space O(1)
Common pitfalls
- mid*mid overflow
- Float precision issues
Your solution
Log in to save your code and track progress.