One Testcase not giving WA
Hi @alamsarfraz422
ur appraoch is not correct…
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
refer this https://ide.codingblocks.com/s/622508
I hope its clear now??
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.