leetcode_algorithm9.Palindrome Number

題目:

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]

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章