【leetCode】9_回文数

class Solution {
public:
    bool isPalindrome(int x) {
        int n = x;
        string s;
        stringstream ss;
        ss << n;
        ss >> s;
        int length = s.length();
        int i = 0, j = length - 1;
        while (s[i] == s[j] && j > i){
            i ++;
            j --;
        }
        if (j <= i){
            return true;
        }
        else{
            return false;
        }
    }
};

 

你可能感兴趣的:(leetCode)