Description
https://leetcode.com/problems/longest-palindromic-subsequence/description/
Solution
The code is quite straightforward. The recursive formule is the following:
The string range from i to j can be reduced to the smaller case by two situations:
If the char at i and j is equal, then the largest prlindromic subseq is [i+1, j-1] + 2
Else, the largest prlindromic subseq is the larger value of [i+1, j], [i, j+1]
1 | class Solution { |