Count the substrings of s that are palindromes (substrings at different positions count separately, even if they look the same).
For "aaa" the answer is 6.
The starter code expands around every centre separately. It is correct but too slow on long repetitive strings.
Example 1
Input:
count_palindromes_fast('aaa')
Output:
6
Example 2
Input:
count_palindromes_fast('abc')
Output:
3
0 <= len(s) <= 200000No results yet
Run your code to check it against the examples, or submit to run every test.