516. Longest Palindromic Subsequence
516. Longest Palindromic Subsequence
Description
Given a string s
, find the longest palindromic subsequence ‘s length in s
.
A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.
Example 1:
1 | Input: s = "bbbab" |
Example 2:
1 | Input: s = "cbbd" |
Constraints:
1 <= s.length <= 1000
s
consists only of lowercase English letters.
Hints/Notes
- 2024/07/19
- range dp
- note: subsequence not substring
- 0x3F’s solution(checked)
Solution
Language: C++
1 | class Solution { |