Palindromic Substrings

Medium · Strings · String · Dynamic Programming · Two Pointers

Problem

Count how many substrings of s are palindromes. Substrings at different positions count separately even if they are identical.

Examples

Input: s = "abc"
Output: 3

The three single characters.

Input: s = "aaa"
Output: 6

"a" three times, "aa" twice, and "aaa".

Constraints

Approaches

Related problems

Start free on Cariara · Coding problems · System design studio

Starting Python
No results yet.

          
↑↓ move ↵ open esc close

Labs

Loading labs…

Run with your own input

Starting Python

Loading Python…