LCS with 3 strings


code is giving output as 0 what is wrong in the code?

@aryamaan1011,
You should dry run on sample test case to find where in your dp table wrong values is being filled.
On the sample test case, draw and fill a correct dp table on paper, and print the code’s one on screen. Then you can compare and see where the values goes wrong, and debug.

@aryamaan1011,
You aren’t considering cases when not all 3 but any 2 of them match eg, s1[i-1]==s2[j-1]!=s3[k-1]. You have to handle these cases also, as it may happen that you make a subset using two strings now, and it gets matched with the 3rd string later, thus giving a better answer.