-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMAXSUBARRYS1.java
More file actions
31 lines (26 loc) · 845 Bytes
/
Copy pathMAXSUBARRYS1.java
File metadata and controls
31 lines (26 loc) · 845 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
import java.util.*;
public class MAXSUBARRAYS1 {
public static void UPDATE(int numbers[]) {
int current = 0;
int largest = Integer.MIN_VALUE;
for (int i = 0; i < numbers.length; i++) {
int start = i;
for (int j = i + 1; j < numbers.length; j++) {
int end = j;
current = 0;
for (int k = start; k < end; k++) {
current = current + numbers[k];
}
System.out.println(current);
if (current < largest) {
current = largest;
}
}
}
System.out.println(current);
}
public static void main(String args[]) {
int numbers[] = { 2, 4, 6, 8, 10 };
UPDATE(numbers);
}
}