func isPalindrome(x int) bool {
    if x < 0 {
        return false
    }
    
    var rev int
    origX := x
 
    for x != 0 {
        rev = rev * 10 + x % 10
        x /= 10
    }
 
    return rev == origX
}

Complexity

Time: — where is number of digits
Space: