Printing is wrong but length of lcs comes out is correct
if(a[i-1]==b[j-1]){
s+=a[i-1];
i--;
j--;
}
else if(dp[i-1][j]>dp[i][j-1]){
i--;
}
else{
j--;
}
you had to else if, you were doing if.
thanks for solving all my dp related doubts now it code works
1 Like