赞
踩
- class Solution:
- def isPalindrome(self, x: int) -> bool:
-
- to_string = str(x)
-
- i = 0
- q = len(to_string)-1
-
- front = to_string[i]
- rear = to_string[q]
-
- while front == rear:
- if i==q or abs(i-q)==1:
- return True
-
- i += 1
- q -= 1
- front = to_string[i]
- rear = to_string[q]
-
- return False
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。