标签归档:leetcode

RSS feed of leetcode

[LeetCode]Integer to English Words

题目描述:

Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 2 ^ 31 - 1.

For example,

123 -> "One Hundred Twenty Three"
12345 -> "Twelve Thousand Three Hundred Forty Five"
1234567 -> "One ...

继续阅读

[LeetCode]Sqrt(x)

题目描述:

Implement int sqrt(int x).

Compute and return the square root of x.

题目大意:

实现函数 int sqrt(int x).

计算并返回x的平方根(整型)

解题思路:

题目并不要求计算sqrt(x)的精确值,只需返回小于等于sqrt(x)的最大整数即可。

方法I:二分法

Python代码:

class Solution(object):
    def mySqrt(self, x):
        """
        :type ...

继续阅读