Entrance: Two-dimensional array NxN - Matrix - with numbers from 0 to 9.
Conclusion: The largest rectangular region, where the absolute value of the difference of numbers in the region k .
Possible input:
int k=3; const int N=5; int matrix[N][N] = {{9, 3, 8, 2, 0}, {2, 7, 6, 8, 5}, {8, 5, 7, 7, 6}, {3, 0, 4, 0, 9}, {7, 2, 0, 4, 0}};
Is this related to finding the largest area in the histogram problem? If he does, how can I convert this matrix to two binary matrices? And how to approach such problems?
Answer: the largest area is 8 by the next submatrix {{7, 6, 8, 6}, {5, 7, 7, 6}}
What I should do:
- Convert matrix to binary matrix
- Creating a binary matrix histogram
- Calculate the largest area using the largest area in the histogram.
It is not clear how to convert the input matrix to a binary matrix.
algorithm matrix
Khamidulla Sep 22 '14 at 1:15 2014-09-22 01:15
source share