1、问题描述
2、问题分析
对于每一个字符,以该字符为中心计算回文个数。
3、代码
int countSubstrings(string s) {
int count = ;
if( s.size() == )
return ; for( int i = ; i < s.size(); i++){
count += checkPalindromic(s, i,i);
count += checkPalindromic(s, i, i+);
} return count ;
} int checkPalindromic( string s ,int i ,int j ){
int count = ;
while( i >= && j < s.size() && s[i] == s[j]){
i--;
j++;
count++;
}
return count;
}