LeetCode/릿코드-Pailndrome Number-python

cosmos·2021년 8월 20일
0
post-thumbnail
post-custom-banner

문제

풀이

  • given an intger 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 123is not.
  • contraints : -2 ^ 31 <= x <= 2^31 -1
  • follow up : could you solve it without converting the integer to a string.

코드

# leetcode, easy : Pailndrome Number, python3
class Solution:
    def isPalindrome(self, x: int) -> bool:
        return True if str(x) == str(x)[::-1] else False

결과



출처 && 깃허브

LeetCode
github

post-custom-banner

0개의 댓글