The optimal approach is not giving the correct answer like the other approches

In the Question,

Find the sum of all Sub-Matrices in the given Matrix, the 3 approach explained does not given the correct answer like the other two approaches.

My code -> https://ide.codingblocks.com/s/364989

hello @Shivam01 all other two approaches which you have tried are working ?

i will see your code but for you knowledge i want you to know that in cp there is no need to deal with every approach possible .
so if you have got correct answer from one approach then it is fine you should just move on to another question to try .
i will see your code and let you know the error please wait .

Yes you are right but its the most optimal approach which is giving me error. So can you please explain that to me. Also it is not a CP Problem, I think so. So can you please help.:blush:

hey @Shivam01 your logic and the implementation was correct but you were not taking the input in the correct manner .
now i have done some changes and now it is printing the correct result .


please see this code and tell me if you dont understand anything .
Happy Learning !!

If my matrix size exceeds (61*61) then it shows different outputs. Can you help??

@Shivam01 aayush please take the matrix whose answer you know .
could you please share the input which you are giving ?

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.