I am trying to write a program in Java which, when specifying the matrix MxN, will find the (adjacent) submatrix with the largest sum of numbers. Then the program needs to return the upper left corner coordinates of the submatrix and the lower right corner coordinates. The matrix can contain negative numbers, and both the matrix and the submatrix must not be square.
I saw this discussed here: Getting the submatrix with the maximum amount? , and the solution there seems to be O (n ^ 3). A friend of mine said that they were able to solve this problem in O (n ^ 2). Also offered here. Is it possible?
Is there any code available that solves this problem in the most efficient way?
source
share