Description
Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well. You must not use any built-in exponent function or operator.
Examples
Input:
x = 4Output:
2Explanation:
The square root of 4 is 2.
Input:
x = 8Output:
2Explanation:
The square root of 8 is 2.82842..., rounded down to 2.
Input:
x = 1Output:
1Explanation:
The square root of 1 is 1.
Input:
x = 0Output:
0Explanation:
The square root of 0 is 0.
Constraints
- •
0 ≤ x ≤ 2³¹ - 1