One test case does not passes? I am unable to understand the reason.
Print LCS(One Test case fails)
If both dp[i][j-1] and dp[i-1][j] are equal. Than we have a choice to either move left or up? Or is it a constraint to move upward. If it is constraint, please explain the reason.
What is the test case for which it goes wrong? Please share it
hey @yfulwani82, this is the input
qwertyuioplmznchskalcmnbxghfjtklmnzxcbvnmjkanslpaoutrinvmakldkslqwertyuioplmznchskalcmnbxghfjtklmnzxcbvnmjkanslpaoutrinvmakldkslqwertyuioplmznchskalcmnbxghfjtklmnzxcbvnmjkanslpaoutrinvmakldkslqwertyuioplmznchskalcmnbxghfjtklmnzxcbvnmjkanslpao (string 1 ends here)
lakdmshvndmxnvjrtyuiopqwertlakdmshvndmxnvjrtyuiopqwertdkslpensismfnvheksndertdkslpensismfnvheksndertdkslpensismfnvheksnd (string 2 ends here)
Correct output
lakmvnmnvrtyuioplakmvnmnvrtyuioplnsmfnvksndksleimnhkntklmnvks
It has two answers both of length 61.
hey @yfulwani82, it has only one answer that I have already given you might be you are not able to understand because of long length.
string 1 of input
qwertyuioplmznchskalcmnbxghfjtklmnzxcbvnmjkanslpaoutrinvmakldkslqwertyuioplmznchskalcmnbxghfjtklmnzxcbvnmjkanslpaoutrinvmakldkslqwertyuioplmznchskalcmnbxghfjtklmnzxcbvnmjkanslpaoutrinvmakldkslqwertyuioplmznchskalcmnbxghfjtklmnzxcbvnmjkanslpao
string 2 of input
lakdmshvndmxnvjrtyuiopqwertlakdmshvndmxnvjrtyuiopqwertdkslpensismfnvheksndertdkslpensismfnvheksndertdkslpensismfnvheksnd
It has two answers. If you want to verify please enter the strings in reverse order i.e. string1 as string2 and vice versa, you will see a different output as given by you
And that too of same length 61
hey @yfulwani82, May be it has 2 outputs, but for above testcase output stored is lakmvnmnvrtyuioplakmvnmnvrtyuioplnsmfnvksndksleimnhkntklmnvks