LCS Print Atcoder

Hi! My code is giving me TLE when I submit it on Atocoder.
Please tell me what’s wrong.

@sm26175
You was doing dp[i][j] != 0, but you have to do dp[i][j] != -1 to memoise it properly.
because dp[i][j] could be zero, and you might be calculating it again.

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.