Q:
Implement int sqrt(int x)
.
Compute and return the square root of x.
A:
class Solution(object):
def mySqrt(self, x):
"""
:type x: int
:rtype: int
"""
return int(x ** 0.5)
(ノ ̄▽ ̄) py的优势
Q:
Implement int sqrt(int x)
.
Compute and return the square root of x.
A:
class Solution(object):
def mySqrt(self, x):
"""
:type x: int
:rtype: int
"""
return int(x ** 0.5)
(ノ ̄▽ ̄) py的优势