-
Notifications
You must be signed in to change notification settings - Fork 0
/
Compare_the_Triplets.java
59 lines (39 loc) · 1.47 KB
/
Compare_the_Triplets.java
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Challenge link : https://www.hackerrank.com/challenges/compare-the-triplets/problem?isFullScreen=true
// Git Hub REPO Link : https://github.com/piyushpatelcodes/100-Days-Java-Hackerrank
import java.util.*;
import java.io.*;
public class Compare_the_Triplets{
public static int compare(int a[], int b[]){
int aliceScore = 0;
int bobScore = 0;
List<Integer> scores = new ArrayList<>();
for(int i = 0; i < 3; i++) {
if (a[i] > b[i]) {
aliceScore++;
}
if (a[i] < b[i]) {
bobScore++;
}
}
scores.add(0,aliceScore);
scores.add(1,bobScore);
System.out.print(scores.get(0) + " " + scores.get(1));
return 0;}
public static void main(String args[]){
int n = 3 ;
Scanner sc = new Scanner(System.in);
int[] a = new int[3];
// System.out.println("Enter the elements of the array: ");
for(int i=0; i<n; i++)
{
a[i]=sc.nextInt();
}
int[] b = new int[3];
// System.out.println("Enter the elements of the array: ");
for(int i=0; i<n; i++)
{
b[i]=sc.nextInt();
}
compare(a, b);
}
}