solve the maximal rectangle problem.