Jesse loves playing with strings, so Wanda gives him two strings, A and B, and asks him to find the length of the longest palindrome that can be fomed using the characters from two palindromic subsequences such that one palindromic subsequence is chosen from A and the other palindromic subsequence is chosen from B.
Jesse has no idea of how to do this; can you help him solve Wanda’s problem?
First argument of input contains a string A Second argument of input contains a string B
return a single integer denoting length of longest palindrome that can be formed from two palindromic subsequences.
1 <= |A|, |B| <= 1000
Input 1: A = "abba" B = "bccb" Ouput 1: 8 Explanation 1: we choose the palindromic subsequences abba from A and bccb from B. The longest palindrome we can form is abbccbba. Input 2: A = "abccdba" B = "zxdyyz" Output 2: 10 Explanation 2: we choose the palindromic subesequences abccba from A and zyyz from B. The longest palindrome we can form is abczyyzcba.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.