Skip to content

leet code palindrome-numbers

very easy..

==="c++(time faster than 40.63%, memory less than 8.38%)" ```c++ class Solution { public: bool isPalindrome(int x) { if(x<0) return false; vector aa; while(x) { aa.push_back(x%10); x /= 10; }

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
    int lenAa = aa.size();
    for(int i=0; i<lenAa/2; ++i)
    {
        if(aa[i]!=aa[lenAa-1-i])
        {
            return false;
        }
    }
    return true;

}

}; ```