Issue in forming logic

So in this the prefix dp that needs to be formed will that store number of gold coins? or total sum till that point

Hey @pranjalarora98
Just take prefix sum of every row and after that take prefix sum of every column.
Then if you partition the (i,j)th of grid then your top-left box sum will be the value at (i,j)th index of grid
and top-right box sum will be the sum at that row’s last column - the sum of top-left box sum
and bottom right box sum will be the value at (n,j)th of grid - the sum of top-left box
and bottom-right box sum will be the value at (n,m)th of grid - top-right box sum - bottom left box sum + the sum of top-left box ( because it get subtracted two times , first time in top-right box sum and second time in bottom-left box sum ).
Make ans at every step as
ans = max ( ans, min( all four boxes) );

Just take prefix sum of every row and after that take prefix sum of every column.
So means initially my dp[i[[j] will store sum of i rows and j coloumns .LIKE THAT?

I am just getting confused by prefix sum
means 1,2 will be sum of all elements from coloumn 0 to coloumn 2 in 1st row?
and plus the sum obtained by row0 and row 1 for that particular coloumn?

dp[i][j] == sum of matrix with top left corner at 0,0 and bottom right corner at i,j

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.