Maximum Sum Rectangle
You are given a matrix ‘ARR’ with ‘N’ rows and ‘M’ columns. Your task is to find the maximum sum rectangle in the matrix.
Maximum sum rectangle is a rectangle with the maximum value for the sum of integers present within its boundary, considering all the rectangles that can be formed from the elements of that matrix.
For Example
Consider following matrix:
The rectangle (1,1) to (3,3) is the rectangle with the maximum sum, i.e. 29.
Input Format
The first line of input contains an integer ‘T’ denoting the number of test cases to run. Then the test cases follow.
The first line of each test case contains two space-separated integers ‘N’ and ‘M’ denoting the number of rows and number of columns respectively.
The next ‘N’ lines contain ‘M’ space-separated integers denoting the elements of ARR.
Output Format
For each test case, print the value of the sum for the maximum sum rectangle.
Print the output of each test case in a separated line.
Note
You do not need to print anything; it has already been taken care of. Just implement the given function.
Constraints
1 <= T <= 10
1 <= M, N <= 75
-10^5 <= ARR[i][j] <= 10^5
Time Limit: 1 sec
Be the first one to answer
Add answer anonymously...
Top Go-Jek Android Engineer interview questions & answers
Popular interview questions of Android Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app