2-line Python solution, easy but not optimal. Suggestions?


  • 0
    Y

    class Solution(object):
    def isPalindrome(self, x):
    """
    :type x: int
    :rtype: bool
    """
    x = str(x)
    return all(x[i-1]==x[-i] for i in range(1, len(x)//2+1))


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.