Delete The String
Practice
0 (0 votes)
Medium
Problem
32% Success 96 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
3 votes
Tags:
AlgorithmsBitmaskDynamic ProgrammingDigitDP4D dynamic programming
Points:30
7 votes
Tags:
Binary SearchImplementationDynamic ProgrammingAlgorithms4D dynamic programming
Points:30
3 votes
Tags:
MediumAlgorithmsMathematicsOpenApprovedGame Theory
Editorial

No editorial available for this problem.