[LeetCode] 9. Palindrome Number

원숭2·2022년 1월 14일
0

LeetCode

목록 보기
1/51

문제

풀이

  1. int인 입력값을 str으로 변환 후, 문자열 슬라이싱을 이용
    ([::-1] -> 뒤집어 주는 효과)

코드

class Solution:
    def isPalindrome(self, x: int) -> bool:
        res = str(x)
        
        if res[::-1] == str(x) :
            return True
        else :
            return False

0개의 댓글