Given a 2D matrix find the maximum submatrix sum in it. The matrix is containing positive and negative integers. For example The maximum submatrix sum is 15 in the below given matrix.

maximum submatrix sum problemFig. 1.0

maximum submatrix sum problem

The maximum submatrix sum problem can be consider as the extension of “Maximum contiguous sub array problem“.┬áKadane’s algorithm is used to find maximum sub array problem in 1 dimensional array (http://wikistack.com/maximum-subarray-problem/). We can extend the Kadane’s algorithm for 2D array to find maximum submatrix sum. Kindly see below figure for dynamic programming solution.

maximum submatrix sum problem

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=44