104. Longest Palindromic Subsequence
MediumDynamic programming
Return the length of the longest subsequence of s that reads the same forwards and backwards. A subsequence keeps the order of characters but may skip some.
Example 1
Input: s = "bbbab" Output: 4 Explanation: "bbbb"
Example 2
Input: s = "cbbd" Output: 2
Constraints
0 ≤ s.length ≤ 1000