Linctode-37 Python语言
程序员文章站
2022-03-24 17:20:39
...
题目
解法一
class Solution:
"""
@param number: A 3-digit number.
@return: Reversed number.
"""
def reverseInteger(self, number):
# write your code here
x=number//100
y=(number%100)//10
z=number%10
return z*100+y*10+x
运行时间:101ms
解法二
class Solution:
"""
@param number: A 3-digit number.
@return: Reversed number.
"""
def reverseInteger(self, number):
a=str(number)
b=a[2]+a[1]+a[0]
return int(b)
运行时间:101ms