Input:
mat[][] = {{1, 1, 1},
{1, 1, 1},
{1, 1, 1}}
A = 2, B = 1
Output: 2
Explanation: Any submatrix of size 2 X 1 or 1 X 2 will have 2 1s in it.
Input:
mat[][] = {{1, 1, 0, 1, 1, 1, 0, 0},
{0, 1, 0, 1, 1, 1, 1, 1},
{1, 1, 0, 0, 1, 0, 0, 1},
{0, 1, 1, 1, 1, 0, 1, 0},
{0, 1, 1, 0, 1, 1, 0, 1},
{0, 1, 1, 0, 0, 1, 0, 1},
{1, 0, 0, 0, 1, 1, 0, 1},
{0, 1, 1, 0, 1, 1, 1, 1},
{0, 1, 1, 1, 0, 1, 0, 1},
{1, 1, 0, 1, 1, 0, 1, 1}}
A = 4, B = 9
Output: 20
Explanation:
Submatrix from (0, 0) to (8, 3) of dimensions 9 × 4 have 20 1s present in it, which is minimum possible for this matrix.