一、题目
Palindrome Number
二、解题
判断一个数字是否是回文串。
左边:使用字符串来操作
右边:使用数字来操作
感觉这题怎么样都可以实现。
三、尝试与结果
class Solution(object):
def isPalindrome(self, x):
if x < 0 :
return False
i = 0
while i < len(str(x))/2:
left = str(x)[i]
right = x/(10 ** i) % 10
if int(left) != right:
return False
i = i + 1
return True
结果:AC