Palindromic Substrings
Count how many contiguous pieces of s read the same forwards and backwards. Pieces at different positions count separately even when they look alike, and a single character counts as a piece.
Example 1
s "abc"
returns 3
Only a, b, c: 3.
Example 2
s "aaa"
returns 6
Three a, two aa, one aaa: 6.
Constraints
1 <= len(s) <= 50- Lowercase letters only
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.