leetcode python 刷题记录,从易到难
一、题目
二、解答
1.思路
转换成字符串,判断反转后的和未反转的是否相等,相等返回True,否则返回False。
2.实现
class Solution(object):
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
result = str(x)
if result[::-1] == str(x):
return True
else:
return False
3.提交结果
三、Github地址
https://github.com/m769963249/leetcode_python_solution/blob/master/easy/9.py