Check all possible sub-matrix
for the largest one. For doing this, you need many nested
loops like the following.
for(i=0;i<n;i++)
///
{
/// claculation start position
for(j=0;j<n;j++)
///
{
for(int k=0;(k+i)<n;k++) ///row count
{
for(int l=0;((l+j)<n) && t;l++)///coloumn count
{
for(int x=0;(x<=k)&& t;x++)
{
...... .......
...... .......
...... .......
...... .......
}
}
}
}
}
This brute force
approach can solve this problem within its time limit.