69. Sqrt(x)
Input: 4
Output: 2Input: 8
Output: 2
Explanation: The square root of 8 is 2.82842..., and since
the decimal part is truncated, 2 is returned.class Solution(object):
def mySqrt(self, x):
"""
:type x: int
:rtype: int
"""
r = x
while r*r>x:
r = (r+x/r)/2
return rLast updated