forked from alexprut/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Solution.java
36 lines (31 loc) · 867 Bytes
/
Solution.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
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] cache = new int[100];
int min = Integer.MAX_VALUE;
int n = sc.nextInt();
int[] A = new int[n];
for (int i = 0; i < n; i++) {
A[i] = sc.nextInt();
if (A[i] < min) { min = A[i]; }
}
int m = sc.nextInt();
int[] B = new int[m];
for (int i = 0; i < m; i++) {
B[i] = sc.nextInt();
}
for (int i = 0; i < n; i++) {
cache[A[i]-min]++;
}
for (int i = 0; i < m; i++) {
cache[B[i]-min]--;
}
for (int i = 0; i < 100; i++) {
if (cache[i] != 0) {
System.out.print((min+i) + " ");
}
}
}
}