-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompTrip.java
More file actions
34 lines (29 loc) · 1010 Bytes
/
compTrip.java
File metadata and controls
34 lines (29 loc) · 1010 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
import java.util.List;
import java.util.ArrayList;
public class compTrip {
public static List<Integer> compareTriplets(List<Integer> a, List<Integer> b) {
List<Integer> result = new ArrayList<>();
result.add(0);
result.add(0);
for (int i = 0; i < a.size(); i++) {
if (a.get(i) > b.get(i)) {
int currentVal = result.get(0);
currentVal ++;
result.set(0, currentVal);
}
else if (a.get(i) < b.get(i)) {
int currentVal = result.get(1);
currentVal ++;
result.set(1, currentVal);
}
System.out.println(result);
}
return result;
}
public static void main(String[] args) {
List<Integer> a = new ArrayList<>(List.of(1, 2, 3));
List<Integer> b = new ArrayList<>(List.of(3, 2, 1));
List<Integer> output = compareTriplets(a, b);
System.out.println("Output: " + output); // Output:
}
}