13,800,574 members

Email

Password

Sign in with

See more:

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

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);
}
}
```

Comments

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Copyright © CodeProject, 1999-2018

All Rights Reserved.

All Rights Reserved.

CodeProject,
503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada
+1 416-849-8900 x 100