Kunal is pro when it comes to String problems, but this time things didn't go in his favor and he stuck in a problem.
The problem statement says:
You are given two strings S1 and S2 and you have to delete both the strings by deleting atmost one character at a time in any of the 4 possible ways.
1st way : Delete only leftmost character of S1.
2nd way : Delete only rightmost character of S1.
3rd way : Delete only leftmost character of S2.
4th way : Delete only rightmost character of S2.
Just before deleting any character you also get a goodness score which is the length of common subsequence of remaining strings S1 and S2.
Help Kunal in deleting the strings in a way such that sum of all the goodness scores he gets in the process is maximum possible.
Input Format:
First Line contains String S1.
Second Line contains String S2.
Output Format:
A single integer representing the maximum possible sum of goodness scores following the rules given to delete both strings.
Constraints:
0 < length(S1), length(S2) < 51
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
No editorial available for this problem.