Question bank › Matrix
Dsa Matrix Medium

Matrix Submatrix with Sum

You have a 2D matrix and need to find a submatrix that has the maximum sum. A submatrix is defined by two rows and two columns, given the constraints that it must be rectangular. You are to return the maximum sum of any submatrix that can be formed from the matrix. Input format: The first line contains two integers m and n (1 <= m, n <= 100), the dimensions of the matrix. The next m lines contain n integers each, representing the matrix. Output format: Print a single integer, the maximum sum of the submatrix. Example: Input: 3 3 1 -2 -1 -8 0 2 3 1 5 Output: 7

Key concepts

matrixsubmatrixsum

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.