Expand Around Center

Longest Palindromic Substring 2

January 4, 2024
medium
Expand Around Center

Problem # Given a string s, find the longest palindromic substring in s. Example: Input: s = "babad" Output: One of "bab" or "aba" (since both are valid longest palindromic substrings). Solution # Solution Approach # Algorithm: Expand Around Center This approach involves expanding around every possible center of a palindrome in the string. A palindrome can be centered around one letter (for odd length) or two letters (for even length). ...