Palindromic Substrings
MediumDynamic Programming
Decode it first. Clues, constraints, pattern and plan before any code.Return how many substrings of s are palindromes. Substrings at different positions count separately, even if they contain the same letters.
s = "abc" → 3 ("a", "b", "c")
s = "aaa" → 6 ("a" three times, "aa" twice, "aaa")Constraints
1 <= s.length <= 1000scontains only lowercase letters.