My Code is not working!

I wrote the same logic as explained in the video, but this code is giving garbage value to me.

Is there any error in the explained concept in the video, or the error is in my code?

Please explain the error & provide the correct solution🙏

My Code -> https://ide.codingblocks.com/s/362027

hello @Shivam01

here when i=0 or j=0 , i-1 and j-1 will be -1 and we cannot access negative indices right?
so either it will through some error or some garbage value.

so to avoid it handle i=0 or j=0 case seprately

Now I am improved my code & it’s not showing me garbage value, but not showing me the corrdct answer.

Can you please help in providing the correct solution. My code -> https://ide.codingblocks.com/s/362112

check now->

the formulas were incorrect

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.