647. Palindromic Substrings
class Solution {
public:
int findPalindrome(string s, int l, int r) {
int count = 0;
while(l >= 0 && r < s.size() && s[l] == s[r]) {
count++;
l--;
r++;
}
return count;
}
int countSubstrings(string s) {
int result = 0;
for(int i = 0; i < s.size(); i++) {
result += findPalindrome(s, i, i);
result += findPalindrome(s, i, i+1);
}
return result;
}
};