count_palindromic_substrings(s) that returns the total number of substrings of s (including single characters) that are palindromes. Use the "expand around center" technique: every palindrome has a center (a single character, or the gap between two characters), so try expanding outward from each of the 2 * len(s) - 1 possible centers.s = 'aaa'
6
Palindromic substrings: 'a', 'a', 'a', 'aa', 'aa', 'aaa' = 6 total.
s = 'abc'
3
Only the three single characters are palindromes; no longer substring matches.
For each index i, expand around center i (odd-length palindromes) and around the gap between i and i+1 (even-length palindromes).
Every successful expansion step counts one more palindrome.