Palindromic Substrings
MediumP2Coding
Return the number of palindromic substrings of s. Substrings are counted by position, so the same text at different positions counts separately.
Example 1
- Input
- s = "abc"
- Output
- 3
Example 2
- Input
- s = "aaa"
- Output
- 6
Example 3
- Input
- s = "a"
- Output
- 1
Constraints
- 1 <= s.length <= 1000
- s consists of lowercase letters.
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 12. ⌘Enter runs, ⌘⇧Enter submits.