Palindrome number

Medium
Topics

Palindrome Number

Pattern:

Idea:

Variations :


πŸ’» Code

def isPalindrome(x):
    if x < 0:
        return False

    original = x
    rev = 0

    while x > 0:
        digit = x % 10
        rev = rev * 10 + digit
        x //= 10

    return original == rev

Time complexity - O(D) , D is no of digits

Aux. Space complexity - O(1)


Local Graph View

Start typing to search
Try: two sum or #Arrays or #Amazon