K-Ordered LCS problem


It is giving wrong output to some cases

Hi
Can you pls explain what logic have you used? Through comments or here.
Also do take care, you can only change atmost k elements in the first sequence to any value you wish to, not in the second sequence

here i am taking two cases that in first case if one letter of first stirng is equal to that of other than there are three cases for that

in first i am ignoring ith letter of s1,and in second jth of s2 and in third i am eplacing ith letter in s1 so that it becomes equal to that of s2,similarly for second case

Hey
For:
6 5 2
1 2 3 4 5 6
5 3 1 4 2
Your answer is 4, Can you tell me in what scenario you can get 4 length sub sequence from this, by editing elements of first sub sequence only?

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

in first string 1 can be changed to 5 and 5 can be changed to 2
new first string becomes : 5 2 3 4 2 6
second string : 5 3 1 4 2
LCS : 5342