FunctionRacerProblemsRace

Longest Palindromic Substring

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

Return the longest contiguous piece of s that reads the same forwards and backwards. If several pieces tie for the longest length, return the one that starts earliest in s.

Example 1

s "babad"
returns "bab"

bab and aba tie; bab starts first.

Example 2

s "cbbd"
returns "bb"

bb.

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