516 Longest Palindromic Subsequence
1. Question
Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000.
Example 1: Input:
Output:
One possible longest palindromic subsequence is "bbbb".
Example 2: Input:
Output:
One possible longest palindromic subsequence is "bb".
2. Implementation
(1) DP
3. Time & Space Complexity
DP: 时间复杂度O(n^2), 空间复杂度O(n^2)
Last updated