647. Palindromic Substrings

Practice Palindromic Substrings for free on NudgeCode: Medium, Dynamic Programming pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Count the substrings of s that read the same forwards and backwards. Substrings at different positions count separately, even if they contain the same letters.

Example

s = "abc"  ->  3   ("a", "b", "c")
s = "aaa"  ->  6   ("a" x3, "aa" x2, "aaa")

Constraints