Longest Palindromic Subsequence
Given a string s, find the length of its longest palindromic subsequence.
A subsequence is what remains after deleting some characters (possibly none) without reordering the rest, so unlike a substring it may skip. A palindrome reads the same forwards and backwards.
s = "bbbab"
4
Deleting the 'a' leaves "bbbb", which reads the same both ways. No longer palindromic subsequence exists, so the answer is 4.
s = "abacb"
3
Keeping indices 0, 1, and 2 gives "aba". Nothing of length 4 works here, so the answer is 3.
1 <= s.length <= 1000sconsists of lowercase English letters