Can you please explain how to approach this problem, also with a sample test case…
K - Ordered LCS
You are given two arrays and you have to find k-ordered LCS which means that you can change at most k elements and you have to find the LCS then. So you can simply approach this problem by finding length of normal LCS of the two arrays first. Then add k to it. Finally display the value obtained.
Here is your corrected code. I have added comments. Please check it.