5-lines C++ Solution


  • 0
    F
    bool isPalindrome(int x) {        
            if(x<0) return false;  
            int len=(int)log10(x)+1;
            for(int start=0, end=len-1; start<end; start++, end--)
                if( ((int) ((x/pow(10,start))) % 10) != ((int) ((x/pow(10,end))) % 10) ) return false;        
            return true;
        } 
    

Log in to reply
 

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