Robot collect points

not getting how to find that subgrid ithrough which we can find maximum sum.

@Vishal123
This problem is just about traversing all the possibilities 2-D matrix with the help of recursion.
But one modification here you can do is, you can modify any 5*5 subgrid such that change values from -1 to 0 and others remains same.
Here the width is fixed i.e. 5.
So, For eg if h=7, then you can modify only these subgrids,where h is from 1-5, 2-6, 3-7.

So before traversing the matrix using recursion just modify all the possibile subgrids one by one.

Here i am also attaching my code for reference, after you have understood the problem and not able to solve then only refer to this https://ide.codingblocks.com/s/246305

in your apply power function if h=6 and or_h = 8 then it will convert the subgrid from i=0 t0 i=5 which is a 6x5 subgrid but we want 5x5 subgrid. So I am not able to understand your apply power function

@Vishal123
Ya you are right, thanks for pointing out the mistake. Have a look at same link i have modified the code.
Just added a condition for the start row of the 5*5 subgrid.