Count every palindromic substring
Given a string, count how many of its contiguous substrings are palindromes. Every single character counts as a palindrome, and different positions count separately even if the text is identical.
"abc" -> 3 # "a", "b", "c"
"aaa" -> 6 # "a","a","a","aa","aa","aaa"
Return the total count in time. The brute force checks all substrings at each, which is ; do better.
Show a hint
You already know how to grow a palindrome from a center. What if, instead of tracking the longest one, you just tallied one every time an expansion succeeds?
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.