LeetCode||69. Sqrt(x)
2017-12-05 10:21
483 查看
Implement
Compute and return the square root of x.
x is guaranteed to be a non-negative integer.
Example 1:
Example 2:
取平方根,去尾法
class Solution(object):
def mySqrt(self, x):
"""
:type x: int
:rtype: int
"""
return int(x**.5)
int sqrt(int x).
Compute and return the square root of x.
x is guaranteed to be a non-negative integer.
Example 1:
Input: 4 Output: 2
Example 2:
Input: 8 Output: 2 Explanation: The square root of 8 is 2.82842..., and since we want to return an integer, the decimal part will be truncated.
取平方根,去尾法
class Solution(object):
def mySqrt(self, x):
"""
:type x: int
:rtype: int
"""
return int(x**.5)
相关文章推荐
- 【一天一道LeetCode】#69. Sqrt(x)
- 【LeetCode】69. Sqrt(x) 解题报告
- [leetcode] 69. Sqrt(x) 解题报告
- leetcode 69 sqrt(x)
- Leetcode-69 Sqrt(x)
- LeetCode 69. Sqrt(x)
- 2017.10.19 LeetCode 二分 -> 69. Sqrt(x) -> 410. Split Array Largest Sum
- leetcode 69 sqrt(x)
- 【小熊刷题】sqrt(x) <Leetcode 69 Java>
- The Solution to LeetCode 69 Sqrt(x)
- LeetCode 69. Sqrt(x)
- [leetcode] 69 Sqrt(x)
- LeetCode-69-Sqrt(x)-E
- Leetcode:69. Sqrt(x)
- LeetCode-69.Sqrt(x)
- LeetCode 69. Sqrt(x) (平方根)
- Leetcode刷题记—— 69. Sqrt(x)(求整数x的平方根)
- LeetCode(69) Sqrt(x)
- LeetCode 第 69 题 (Sqrt(x))
- 【leetcode】:leetcode 69 Sqrt(x) 牛顿迭代法