Print longest common subsequence

i am not getting the correct output through this code please tell my mistake in this code
here is my code

Hey @aditikandhway

This is a modified version of your code:

The funciton in which you calculated the dp values was absolutely correct. The only problem was with the x variable. It was not initialized and it was not required. Please go through this version of the code. If I encounter a state in which dp[i][j] != dp[i][j-1] && dp[i][j] != dp[i - 1][j],
this means that both the strings are equal at the index i and j. Else I move in the diection of greater dp value.

If was able to clear your query, please mark the query as resolved!

okay. i understood. THANK YOU!!