Longest Palindromic Subsequence
MediumLeetCode2-D Dynamic Programming
Approach hintTry it first, then revealHide
Let dp[i][j] be the answer for s[i..j], filled by increasing length: equal end characters add 2 to the inner range, otherwise drop one end. Equivalently, it is the LCS of s and its reverse.