Solution: Longest Palindromic Substring
Let’s solve the Longest Palindromic Substring problem using the Dynamic Programming pattern.
Statement
Given a string s, return the longest palindromic substring in s.
Constraints
-
s.length -
sconsist of only digits and English letters.
Solution
So far, you’ve probably brainstormed some approaches and have an idea of how to solve this problem. Let’s ...
A naive approach to this problem is to find all possible substrings and select one longest palindromic substring. For example, consider the string “deed”, which contains 10 substrings: “d”, “e”, “e”, “d”, “de”, “ee”, “ed”, “dee”, “eed”, and “deed”. Out of ...