LeetCode #9 迴文數
思路
- 轉換爲字符串做
代碼
class Solution:
def isPalindrome(self, x: int) -> bool:
st = str(x)
for i in range(len(st)//2 + 1):
if(st[i] != st[len(st)-i-1]):
return False
return True
class Solution:
def isPalindrome(self, x: int) -> bool:
st = str(x)
for i in range(len(st)//2 + 1):
if(st[i] != st[len(st)-i-1]):
return False
return True