
Description
Given a 32-bit signed integer, reverse digits of an integer.
Note:
Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−2^31, 2^31 − 1]. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.
My solution
Python
1 |
class (object): |
- 想法:转换为字符串进行反转
Best Solution
Python
1 |
def reverse(self, x): |
- 想法:
- **意为乘方
- cmp(x,y) 函数用于比较2个对象,如果 x < y 返回 -1, 如果 x == y 返回 0, 如果 x > y 返回 1




近期评论