13,800,574 members
See more:
i have a question in java
The question :

given an 2d array of integer

find the biggest rectangle of the same value

example :

2 , 2 , 2

2 , 2 , 1

1 , 1 , 2

the answer will be : 4 because the biggest rectangle is

2 , 2

2 , 2

i cant make a program in java to solve it

so please if someone know how to solve it in java or

can give me a way to do it please comment

What I have tried:

i tired to write a code but
it not working:
the code:
```public class thefinish {
static int max(int [][]a)
{
int result = 0;
int sum1 = -1;
for(int i=0; i<a.length; i++) {
for(int j=0; j<a[i].length; j++) {
sum1= 0;
for(int k=0; k<a.length; k++) {
for(int l=0; l<a[k].length; l++) {
if(a[i][j]==a[k][l]) {
while(a[i][j]==a[k][l] && l!=a[k].length-1) {
sum1++;
l++;
}
}
else {
sum1=0;
}
if(sum1>result) {
result = sum1;
}

}
}
}
}
System.out.println(result);
return result;
}
public static void main(String[] args) {
int [][]a={ 	{0, 0, 0, 0, 9, 0},
{0, 8, 9, 9, 0, 0},
{0, 8, 9, 0, 0, 0},
{0, 8, 0, 0, 0, 0},
{9, 0, 0, 0, 0, 0},
{0 ,0, 0, 0, 0, 0},};
max(a);

}
}```
Posted 6-Dec-18 10:33am
Updated 6-Dec-18 10:55am
v2
ZurdoDev 6-Dec-18 16:52pm

You need to explain where you are stuck. No one is going to do all of your homework for you.

Top Experts
Last 24hrsThis month
 OriginalGriff 85 Richard MacCutchan 60 Patrice T 60 Akin0 35 1suli0 25
 OriginalGriff 2,628 Richard MacCutchan 2,046 CPallini 948 RickZeeland 656 Patrice T 606