C++ solution of 143ms running time


  • 0
    D

    class Solution {
    public:
    bool isPalindrome(int x) {

        if(x<0) return false;
        vector<int> f;
        
         while(x){
            f.push_back(x%10);
            x/=10;
    }
    
    for(int i=0;i<f.size()/2;i++)
    {
        if(f[i]!=f[f.size()-1-i]) return false;
    }
    
    return true;
    

    }
    };


Log in to reply
 

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