# Count Palindromic Substrings
Implement `count_palindromic_substrings(text: str) -> int`.
Return the number of contiguous substrings of `text` that read the same forward and backward. Count occurrences by their start and end positions, so equal text at different positions counts separately. Every single-character substring is a palindrome.
## Valid Input Domain
- `text` contains lowercase English letters.
## Constraints
- `0 <= text.length <= 5,000`
- The answer fits in a signed 64-bit integer.
## Public Examples
### Example 1
Input: `"abc"`
Output: `3`
Only the three single-character substrings are palindromes.
### Example 2
Input: `"aaa"`
Output: `6`
The palindromic occurrences are three of length one, two of length two, and one of length three.
```hint Choose palindrome centers
Odd- and even-length palindromes have different kinds of centers but can be counted with the same expansion idea.
```
Quick Answer: Practice counting every contiguous palindromic substring by position, including single characters and duplicate text at different indexes.
Return the number of contiguous substrings of text that read the same forward and backward. Count occurrences by their start and end positions, so equal text at different positions counts separately. Every single-character substring is a palindrome.
Valid Input Domain
text
contains lowercase English letters.
Constraints
0 <= text.length <= 5,000
The answer fits in a signed 64-bit integer.
Public Examples
Example 1
Input: "abc"
Output: 3
Only the three single-character substrings are palindromes.
Example 2
Input: "aaa"
Output: 6
The palindromic occurrences are three of length one, two of length two, and one of length three.