Getting a TLE .Please tell the error in the code.
Print longest common subsequence
Hello @shiniagarwal25 in line 28 q=max(dp[i-1][j],dp[i][j-1]); you were doing wrong or it was a mistake because you were doing this q=max(dp[i-1][j],dp[i][j=1]);
this was the reason why it was giving error .
It is still not working
@shiniagarwal25 do you want me to correct the complete code ?
I thought you are more concerned about just why it is giving run time error.
it is still giving tle …please correct the complete code.
@shiniagarwal25 the correction was in line 25 which i mentioned above .
but for your knowledge i want you to know that i dont find your logic correct because if you print your dp matrix you would get to know .
For the sample test case your dp array is printing this
0 0 0
0 1 1
0 1 1
there should be length 2 at last and if it isnot giving the correct output then it wouldnot be able to print correct result .
though i have corrected your logic .
please reply if you still have any doubt .
and if you feel your doubt is cleared please mark this as resolved .
Happy Learning !!
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.