4.Longest Palindromic Subsequence
Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000.
Solution: (DP)
Time complexity: O(n^2). Two nested traversals are needed.
Auxiliary Space: O(n^2). Matrix of size n*n is needed to store the dp array.
Last updated
Was this helpful?