https://leetcode.com/problems/palindromic-substrings/description/

https://www.cnblogs.com/grandyang/p/7404777.html

博客中写的<=2,实际上<=1也是可以的

相当于判断一个大指针内所有子字符串是否可能为回文

class Solution {
public:
int countSubstrings(string s) {
int length = s.size();
int res = ;
vector<vector<bool>> dp(length+,vector<bool>(length+,false));
for(int i = ;i <= length;i++){
for(int j = ;j <= i;j++){
if(s[i-] == s[j-]){
if(i -j <= || dp[i-][j+]){
dp[i][j] = true;
res++;
}
}
}
}
return res;
}
};
上一篇:如何在 C#中的listView 控件中显示图片?


下一篇:Reso | liunx下longeneQQ和搜狗拼音