class Solution {
public:
    //时间n的平方,空间1的方法
    bool isornot(string s){
        string ss = s;
        reverse(s.begin(), s.end());
        return s == ss;
    }
    
    int getLongestPalindrome(string A, int n) {
        // write code here
        int max = 0;
        for(int i = 0; i < n; i++){
            for(int j = i; j < n; j++){
                if(isornot(A.substr(i,j-i+1))){
                    max = max>(j-i+1)?max:(j-i+1);
                }
            }
        }
        return max;
    }
};