- use left point and right point
- right point to find duplicates
- left and right to find palindromic that center of s[i]

```
class Solution {
public:
int countSubstrings(string s) {
int len = s.length();
if(!len) return 0;
int res = 0;
for(int i = 0; i < len;i++)
{
int left = i - 1;
int right = i + 1;
while(right < len && s[right] == s[i])
{
right++;
res++;
}
while(left >= 0 && right < len && s[left] == s[right])
{
left--;
right++;
res++;
}
res++;;
}
return res;
}
};
```