您的位置:首页 > 编程语言 > Python开发

<LeetCode><Easy> 7 Reverse Interger

2015-10-16 22:38 567 查看
Reverse digits of an integer.

Example1: x = 123, return 321

Example2: x = -123, return -321

#Python2 Overflow

class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
return int(str(x)[::-1]) if x >=0 else -int(str(x)[:0:-1])
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  leetcode python