class Solution {
public:
int count = 0;
int countSubstrings(string s) {
for(int i = 0; i < s.size(); i++){
fun_helper(s, i, i); //分两种情况,以自己为中心往两边扩散
fun_helper(s, i, i + 1); //以自己和右的旁边,往两边扩散
}
return count;
}
void fun_helper(string s, int begin, int end){
while(begin >= 0 && end <= s.size()){
if(s[begin] == s[end]){
count++;
begin--;
end++;
}else{
break;
}
}
}
};