69.Sqrt(x)
2019-05-20
69.Sqrt(x)
Implement int sqrt(int x)
.
Compute and return the square root of _x_, where _x_ is guaranteed to be a non-negative integer.
Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned.
Example 1:
1 | Input: 4 |
Example 2:
1 | Input: 8 |
Code:
1 | class Solution(object): |