Please check code for LCS with 3 strings


Not able to pass one test case

hello @sahilkhan2312000131

this logic will fail when first 2 strings will have more than one lcs.

for ex->
abc
acb
abd

here lcs of first 2 strings can be (ab , ac)
if u pick ab and take its lcs with abd then resultant lcs will be of length 2.
if u pick ac and take its lcs with abd then resultant lcs will be of length 1.

clearly ur will fail for above such cases.

use 3d dp to solve this problem

Coding Blocks IDE
Please check the code I have done what you said

check now->

Coding Blocks IDE
Please check this code for Top-down approach for the same

check now->

Thank you so much @aman212yadav

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.