Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Store prefix sum of all grids in another 2D array.
Try all possible solutions and if you cannot find one return -1.
If x is a valid answer then any y < x is also valid answer. Use binary search to find answer.