class Solution {
public:
    int getLongestPalindrome(string A, int n) {
        vector<vector<bool>> dp (n, vector<bool>(n, false));
        int ret = 1;
        for (int i = 0; i < n; i++) {
            dp[i][i] = true;
            for (int j = 0; j < i; j++) {
                if (A[i] != A[j]) {
                    continue;
                } 
                if ((i - j <= 1) || dp[j+1][i-1]) {
                    dp[j][i] = true;                                            
                }
                
                if (dp[j][i]) {
                   ret = ret > i - j + 1 ?ret : i - j + 1;
                }
            }
        }
        return ret;

    }
        // write code here
    
};