Solvarch
DSA ProblemsProgressPlanRoadmapsReviewCheat SheetsCompaniesSystem DesignCS FundamentalsQuestion Bank
Theme
Problems

Palindromic Substrings

Medium
dynamic-programmingstringtwo-pointers

Count the palindromic substrings of s (substrings with different positions count separately).

Input: one line, the string s. Output: the count.

Example 1
Input:
abc
Output:
3

a, b, c.

Example 2
Input:
aaa
Output:
6

a×3, aa×2, aaa.

Constraints

  • 1 ≤ s.length ≤ 1000
  • Lowercase English letters.
Watch a video walkthrough

Run your code against the sample tests, or Submit to run the full suite.