Problem of the day
Input: ‘BLESSING1’ = “asdf” ‘BLESSING2’ = “asdf” ‘K’ = 3
Output: 317
The optimal strategy would be
To have the blessing as “sdf” which results in the total happiness of 115+100+102 = 317.
The first line consists of a number of test cases ‘T’.
The first line of each test case contains the string ‘BLESSING1’.
The second line of each test case contains the string ‘BLESSING2’.
The third line of each test case contains the length of common Subsequence 'K'.
The output consists of ‘T’ lines, each containing an integer that denotes the maximum happiness value the two blessings can generate.
You don't need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= length(BLESSING1), length(BLESSING2) <= 100
Time Limit: 1 sec
2
asdf
asdf
3
anandi
jagya
3
317
0
For the first test case:-
The optimal strategy would be
To have the blessing as “sdf” which results in the total happiness of 115+100+102 = 317.
For the second test case:-
No common subsequence of length 3 is possible hence, the result is 0.
2
axyz
yaxz
2
aaaaaazzzz
zzzzaaaaaa
4
243
488