Medium Accuracy: 80.99%
Submissions: 3858 Points: 4
Given a String, find the longest palindromic subsequence.
S = "bbabcbcab"
Explanation: Subsequence "babcbab" is the
longest subsequence which is also a palindrome.
S = "abcd"
Explanation: "a", "b", "c" and "d" are
palindromic and all have a length 1.
You don't need to read input or print anything. Your task is to complete the function longestPalinSubseq() which takes the string S as input and returns an integer denoting the length of the longest palindromic subsequence of S.
Expected Time Complexity: O(|S|*|S|). Expected Auxiliary Space: O(|S|*|S|).