Problem
Given a non-negative integer x, return its square root rounded down to the nearest whole number. You may not use a built-in power or square-root function (no math.sqrt, **, Math.sqrt or Math.pow).
Example 1
- Input
- x = 4
- Output
- 2
Example 2
- Input
- x = 8
- Output
- 2
- Why
- the real root is 2.828..., rounded down
Example 3
- Input
- x = 0
- Output
- 0
Constraints
0 <= x <= 2^31 - 1