Leetcode 9.回文数 Python

class Solution:
    def isPalindrome(self, x):
        x=str(x)
        rev=""
        for s in x:
            rev=s+rev
        return rev==x

解题思路:

先把x转化为字符串

然后把x反转保存到rev

返回x==rev

打败用户也是挺多的:

Leetcode 9.回文数 Python_第1张图片

 

(p.s.过分简单)


关注我,在Leetcode专栏中查看更多题目的解题思路吧!

你可能感兴趣的:(Leetcode,leetcode,python,算法)