Print lcs failing testcases?


plz look at this code its not passing testcses ,plz mark error a to optimise…

hello @Ashu1318

ur logic is correct.
here we can have multiple answers and cb checker dont support multiple valid answers thats why it is failing.

i have changed ur code that will give expected output.

its working ,but are not they both same ?? afterall in both way we are moving toward index having higher value than other

can u share any example having multiple ans so i will make dp table to apply this way

no they are not same ,
like u have written inclusion step in the last whereas in the code(that i given)
we have written inclusion step 1st.
so if case like this arise->
2 3
3 3 <- we are here
then u will move to top , whereas in given code we will include current character

example where we can have multiple lcs.

s1=> ab
s2=> ba
valid answers -> a or b