My Code is not submitting whats wrong in my code
hi @mohit26900,
EXPLANATION
This problem is simply an extension of LCS
Let the input sequences be X[0…m-1], Y[0…n-1] and Z[0…o-1] of lengths m, n and o respectively. And let L(X[0…m-1], Y[0…n-1], Z[0…o-1]) be the lengths of LCS of the three sequences X, Y and Z. Following is the implementation:
The idea is to take a 3D array to store the length of common subsequence in all 3 given sequences i. e., L[m + 1][n + 1][o + 1]
1- If any of the string is empty then there is no common subsequence at all then L[i][j][k] = 0
2- If the characters of all sequences match (or X[i] == Y[j] ==Z[k]) then L[i][j][k] = 1 + L[i-1][j-1][k-1]
3- If the characters of both sequences do not match (or X[i] != Y[j] || X[i] != Z[k] || Y[j] !=Z[k]) then L[i][j][k] = max(L[i-1][j][k], L[i][j-1][k], L[i][j][k-1])
refer here https://ide.codingblocks.com/s/660320 updated it and commented
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.