Print LCS Problem


Only a is coming as output,it should print ac.Kindly correct.

Hey ,
This is a typically 2D DP question , recursion would not at all be an efficient approach.
Also there are many point of failure in ur code, like initialising a char array with -1
then u are creating a dp array within the lcs function, so basically creating a new dp array for each recursion call,
This would not help us trace back the string which forms Longest common subsequence

I have attached a code snippet, please have a look .
In case of further doubts do comment

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.