-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq8
More file actions
43 lines (40 loc) · 660 Bytes
/
q8
File metadata and controls
43 lines (40 loc) · 660 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
public long getprod( int[] a )
{
long result = 0;
int size = 13;
LinkedList<Integer> list = new LinkedList<Integer>();
int i = 0, k = 0;
while ( i < a.length )
{
list.clear();
k = 0;
while ( k < size )
{
if ( a[i + k] == 0 )
{
i += size - 1;
k = 0;
list.clear();
break;
}
else
{
list.add( a[i + k] );
k++;
if ( k == size )
result = Math.max( result, product( list ) );
}
}
i++;
}
return result;
}
public long product( LinkedList<Integer> l )
{
long res = 1;
for ( int i = 0; i < l.size(); i++ )
{
res = res * l.get( i );
}
return res;
}