Accepted c++ solution, beat 99% runtime


  • 0
    X
    class Solution {
    public:
        bool isPalindrome(int x) {
            int temp = x;
            int reverse = 0;
            while(temp > 0)
            {
                reverse *= 10;
                reverse += temp%10;
                temp /= 10;
            }
           return (x-reverse) == 0 ;
        }
    };
    

Log in to reply
 

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