Input: A 2-dimensional array NxN - Matrix - with numbers from 0 to 9.
Output: Largest rectangular area where absolute value of number's difference in area is 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 it related to find largest area in histogram problem? If it does how I can transform this matrix two binary matrix? And how to approach this kind of problems?
Answer: largest area is 8 by following sub matrix {{7, 6, 8, 6}, {5, 7, 7, 6}}
What I think should be done:
- Transform matrix to binary matrix
- Create histogram from binary matrix
- Calculate largest area using largest area in histogram.
What is unclear is how to transform input matrix to binary matrix.