Runtime: 12 ms, faster than 93.77% of C++ online submissions for Longest Palindromic Substring. Memory Usage: 9.1 MB, less than 63.02% of C++ online submissions for Longest Palindromic Substring.
To find the longest palindromic substring, we can consider dynamic programming. A palindrome reads the same backward as forward, so we can use this property to solve the problem. We define a 2D array ...