Description
Given a string s, return the number of palindromic substrings in it. A substring is a contiguous sequence of characters.
Examples
Input:
s = "abc"Output:
3Explanation:
"a", "b", "c" are palindromes.
Input:
s = "aba"Output:
4Explanation:
The palindromic substrings are: "a" (index 0), "b" (index 1), "a" (index 2), and "aba" (the entire string). Each single character is a palindrome, and "aba" reads the same forwards and backwards.
Input:
s = "racecar"Output:
10Explanation:
The palindromic substrings are: "r", "a", "c", "e", "c", "a", "r" (7 single characters), "cec" (center palindrome), "aceca" (longer center palindrome), and "racecar" (the entire string which is a palindrome).
Constraints
- •
1 ≤ s.length ≤ 1000