Let Code/riteコード-ファイル番号-python


質問する



に答える

  • 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 123 is 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