In this problem when i used a[i][j]=1+a[i-1][j-1] use because when we consider i the element or j th element than that is taken in LCS but my solution on passed all solution in atcoder dp contest link is provided below
https://atcoder.jp/contests/dp/tasks/dp_f
In this problem when i used a[i][j]=1+a[i-1][j-1] use because when we consider i the element or j th element than that is taken in LCS but my solution on passed all solution in atcoder dp contest link is provided below https://atcoder.jp/contests/dp/tasks/dp_f