leetcode-腾讯精选50题-06

Palindrome Number

Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.

  • 将输入的数变成字符串
  • 判断字符串反转后是否相等,及判断是否回文
  • 因为判断结果就是true or flase 故直接返回结果即可
class Solution:
    def isPalindrome(self, x: int) -> bool:
        y = str(x)
        return y == y[::-1]

你可能感兴趣的:(leetcode-腾讯精选50题-06)