Apply a small optimisation to solve the maximal rectangle problem. O(n*m*m) solution, and further improvement can be done.