Ruby solution.


  • 0
    N
    # @param {Integer} x
    # @return {Boolean}
    def is_palindrome(x)
    
        x_rev = 0
        
        x_clone = x
        while x_clone > 0
            x_rev = (x_rev * 10) + (x_clone % 10)
            x_clone = x_clone / 10        
        end
        
        x == x_rev
    end
    

Log in to reply
 

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