Approach 2 to find the sum of submatrices

as the sir is explained the lecture to calculate using prefix sum i am try this in my code but not getting answer try to so had but didnt find my mistake kindly a look to my code and correct me where i am wrong i attached scrrenshots in two posts because it is not allowed to post 2 pics

Hi Dipesh,
pls send whole code or u can refer my code

how i can attach two pictures

in one doubt sir it showing new user can not attach two pics in post

i attach my remaining code in this post

i dont know exactly about this issue… what u can do is copy ur code on coding blocks ide and send link…

ok ok… i got it… just use ternary operators to check if index doesn’t go less than 0… i have updated my code

sir index too humne start hii 0 se kiya hein li lj ko and bi bj tooo negative hoo nahi sakte

yes… but li and lj 0 se start krre hai… and ans compute krte time li-1 and lj-1 bhi krre hai na… to vo negative ja skta hai… isliye check lgnana pdega…

i hope its clear now??

yes sir its clear thanks for the guidance
i need some guidance that for more practice of the covered topics how i do the things

so u can keep practising ques on hacker blocks, geeksforgeeks or leetcode…

how i rate it the doubt u solved sir

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.