題目:
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.
判斷一個整數是否是迴文數,當他從前讀和從後讀都一樣時。
思路:
太簡單了,話不多說,直接上代碼。
代碼:
class Solution:
def isPalindrome(self, x: int) -> bool:
return str(x) == str(x)[::-1]