Return how many substrings of s are palindromes. Substrings at different positions count separately, even if they hold the same characters ("aaa" has 6: three a, two aa and one aaa).
The starter code checks every substring. It is correct but too slow. Make it fast.
Example 1
Input:
count_palindromic_substrings('abc')
Output:
3
Only the three single letters.
Example 2
Input:
count_palindromic_substrings('aaa')
Output:
6
a three times, aa twice, aaa once: 6.
0 <= len(s) <= 1000s contains lower-case letters.No results yet
Run your code to check it against the examples, or submit to run every test.