Determine whether an integer is a palindrome. An integerisapalindrome when itreads the same backward as forward.Coud you solveit without converting the integer to a string? my solution def is_palindrome(x): """ :type x: int :rtype: bool """
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Coud you solve it without converting the integer to a string?
my solution
def is_palindrome(x): """ :type x: int :rtype: bool """ if x >= 0: num_list = [] while x > 0: a = x % 10 x = x // 10 num_list.append(a) rev_num_list = num_list[::-1] return rev_num_list == num_list return False
reference
https://leetcode.com/problems/palindrome-number/submissions/