본문 바로가기

Algorithm

[LeetCode] Palindrome Number

설명

Given an integer x, return true if x is palindrome integer.

An integer is a palindrome when it reads the same backward as forward. For example, 121 is palindrome while 123 is not.

 

예시

 

제한

  • -231 <= x <= 231 - 1

 

 

Palindrome Number - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

 

풀이

class Solution:
    def isPalindrome(self, x: int) -> bool:
        try:
            return x == int(str(x)[::-1])
        except:
            pass