K-ordered longest commmon subsequence

Answer link:https://ide.codingblocks.com/s/50703
Question link:https://www.hackerearth.com/problem/algorithm/mancunian-and-k-ordered-lcs-e6a4b8c6/

Please tell me why the question is showing wrong answer for some test cases.

Hey @Vidushi04
You don’t actually require to use 3d DP in this question.
It can be easily solved using the 2d DP approach.
Go through the code
https://ide.codingblocks.com/s/51687

Try to dry run it on some cases, then you’ll understand the logic better.
And then try to code it yourself with this approach . :slightly_smiling_face: