Sqrt(x)
Return the integer square root of x.
Examples
Input: 4
Output: 2
Input: 8
Output: 2
Hints
Handle edge cases where x is 0 or 1 directly.
Optimize the binary search by adjusting the high bound to min(x, some upper limit like 2^16) to prevent overflow and improve efficiency.
Implement the binary search such that it returns the largest integer whose square is less than or equal to x, ensuring correctness for all edge cases including perfect and non-perfect squares.
Related Problems
Sqrt(x)
Return the integer square root of x.