FunctionRacerProblemsRace

Palindromic Substrings

MediumTwo pointersPython, JavaScript, TypeScript, Java, C++

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Two pointers problems