美文网首页LeetCode
LeetCode-9 - Palindrome Number

LeetCode-9 - Palindrome Number

作者: 空即是色即是色即是空 | 来源:发表于2017-11-14 15:17 被阅读12次

Determine whether an integer is a palindrome. Do this without extra space.

Solution

class Solution(object):
    def isPalindrome(self, x):
        """
        :type x: int
        :rtype: bool
        """
        
        return str(x) == str(x)[::-1]

思考

  1. 有没有办法通过除数/余数就能够完成比较?

相关文章

网友评论

    本文标题:LeetCode-9 - Palindrome Number

    本文链接:https://www.haomeiwen.com/subject/umhfvxtx.html