Given a string s, return the total number of palindromic substrings in s. A substring is counted by position, so identical character sequences at different positions count separately. Pattern focus: Palindrome DP. This is the standard expansion/DP counting problem for palindromic intervals.
s = input string
number of palindromic substrings
Example 1:
Input:
s = "abc"
Output:
3
Explanation:
Each single character is a palindrome.
Example 2:
Input:
s = "aaa"
Output:
6
Explanation:
The palindromic substrings are a, a, a, aa, aa, aaa.