Doubt in max sum submatrix

Hello, could you please explain me why we are using suffix sum matrix ? The max sum can also be find with the help of prefix sum matrix ?

hello @yashsharma4304

yeah u r right, we can find using prefix sum matrix as well.
but by using suffix sum matrix it will be bit easy.
in case of suffix matrix u jsut have to iterate to each cell (i,j) and pick maximum

in case of suffix matrix u jsut have to iterate to each cell (i,j) and pick maximum

And what will happen in case of prefix sum matrix ?

Will I have to iterate over complete array ?

some more subtraction term will be there in case of prefix sum matrix.

1 Like

yeah …u need to iterate on complete matrix and pick maximum from it

ok. thank you :slightly_smiling_face: