Problem 658. Find the biggest empty box

Created by Ned Gulley in ASEE Challenge

You are given a matrix that contains only ones and zeros. Think of the ones as columns in an otherwise empty floor plan. You want to fit a big square into the empty space (denoted by zeros). What is the largest empty square sub-matrix you can find in the given matrix? You will return the row and column extent of the sub-matrix. The answer may not be unique. We will test that your sub-matrix is square, that it is empty, and that it contains the correct number of elements.


 Input a = [ 1 0 0 
             0 0 0 
             0 0 0 ]
 Output si = [ 2 3 2 3 ]

That is, the square indices are a(2:3,2:3). We verify that sum(sum(a(2:3,2:3))) is zero, and that it has four elements.

Solution Stats

42.13% Correct | 57.87% Incorrect
Last solution submitted on Mar 23, 2018

Problem Comments

Solution Comments

Recent Solvers249


Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!