Longest coomon subsequence code error

Getting wrong answer .Please check where I done mistake.
code - https://ide.codingblocks.com/s/317432

hey divesh,
Your logic is correct and i have marked the mistakes in your code.
If you dont understand any mark please let me know.

why we iterate matrix to length of string ,we start the loop from 0 so,we have to take length -1

Hey divesh,
You are right in general we start from 0 and go to n-1,but in this case we are marking first row and first column of matrix as 0.

I get it what you said ,but I have 1 doubt when we take dp of size of string length
then in the last column we get 0 except dp[6][6] in that place we get 4 not 0 .
Why it so .please explain

code -https://ide.codingblocks.com/s/318037