leetcode-9. 回文数

一、问题描述

https://leetcode-cn.com/problems/palindrome-number/description/

二、代码和思路

class Solution:
    def isPalindrome(self, x):
        """
        :type x: int
        :rtype: bool
        """
        x_str=str(x)
        for i in range(len(x_str)//2):
            if x_str[i] != x_str[len(x_str)-1-i]:
                return False
        return True

三、运行结果

猜你喜欢

转载自blog.csdn.net/GrinAndBearIt/article/details/81940719