what’s wrong in this code?
Lcs getting tc failed
hello @rockstarpkm

dont do like this.
compare ith and jth character .if they r eqaul include it .
otherwise checck dp[i-1][j] and dp[i ][j-1]
move towards maximum value
i couldn’t get it…Can you please explain?
it is possible that
dp[i][j]==dp[i-1][j] ,
dp[i][j]==dp[i][j-1] ,
dp[i][j]=1+dp[i-1][j-1] (happens only when s1[i]==s2[j])
so im telling u to first check third case , if it is satisfying then include s1[i] in ur answer and then move i-1 ,j-1.
otherwise check value of dp[i][j-1] and dp[i-1][j] and move towards the maximum value.
still didnt get ?
pls refer this-> link