Skip to content
Onsite

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

Run checks the 3 visible tests, Submit all 12.