Leetcode Palindrome Number Python Solution 判断回文数的python解法

二话不说,直接上代码:

  1 class Solution(object):
  2     def isPalindrome(self, x):
  3         """
  4         :type x: int
  5         :rtype: bool
  6         """
  7         x2 = str(x)
  8         if x2 == x2[::-1]:
  9             return True
 10         else:
 11             return False


一个比较精简的代码


image

运行时间打败了97%的代码

但是很占内存


image

posted @ 2019-07-21 21:35  hungry5656  阅读(167)  评论(0编辑  收藏  举报