https://www.cnblogs.com/grandyang/p/7404777.html
博客中写的<=2,实际上<=1也是可以的
相当于判断一个大指针内所有子字符串是否可能为回文
class Solution { public: int countSubstrings(string s) { int length = s.size(); int res = 0; vector<vector<bool>> dp(length+1,vector<bool>(length+1,false)); for(int i = 1;i <= length;i++){ for(int j = 1;j <= i;j++){ if(s[i-1] == s[j-1]){ if(i -j <= 1 || dp[i-1][j+1]){ dp[i][j] = true; res++; } } } } return res; } };