class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
answer = 0 sign = 1 if x > 0 else -1
x = abs(x)
while x > 0:
answer = answer * 10 + x % 10
x/=10
if answer > 2147483647:
answer = 0
return sign*answer
相关文章
- 03-07leetcode Search in Rotated Sorted Array python
- 03-07[LeetCode&Python] Problem 783. Minimum Distance Between BST Nodes
- 03-07LeetCode 151:给定一个字符串,逐个翻转字符串中的每个单词 Reverse Words in a String
- 03-07LeetCode-151-Reverse Words in s String
- 03-07LeetCode 151. Reverse Words in a String
- 03-07[LeetCode&Python] Problem 27. Remove Element
- 03-07[leetcode] Reverse Linked List 分类: leetcode 算法 2015-07-09 18:44 2人阅读 评论(0) 收藏
- 03-07LeetCode题解(1387):将整数按权重排序(Python)
- 03-07[LeetCode]Divide Two Integer
- 03-07LeetCode题解(1310):子数组异或查询(Python)