// C++ program to find palindromic substrings of a string #include using namespace std; // Returna total number of palindrome substring of // length greater then equal to 2 int CountPS(char str[], int n) { // creat empty 2-D matrix that counts all palindrome // substring. dp[i][j] stores counts of palindromic // substrings in st[i..j] int dp[n][n]; memset(dp, 0, sizeof(dp)); // P[i][j] = true if substring str[i..j] is palindrome, // else false bool P[n][n]; memset(P, false , sizeof(P)); // palindrome of single lenght for (int i= 0; i< n; i++) P[i][i] = true; // palindrome of length 2 for (int i=0; i