-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMissingNumbers.java
More file actions
47 lines (39 loc) · 1.18 KB
/
MissingNumbers.java
File metadata and controls
47 lines (39 loc) · 1.18 KB
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
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int aLen = sc.nextInt();
Integer[] A = new Integer[aLen];
for(int i = 0; i < A.length; i++) {
A[i] = sc.nextInt();
}
int bLen = sc.nextInt();
Integer[] B = new Integer[bLen];
for(int i = 0; i < B.length; i++) {
B[i] = sc.nextInt();
}
sc.close();
int[] result = new int[201];
int pivot = A[0];
for(int i = 0; i < A.length; i++) {
int distance = A[i] - pivot;
result[100 + distance]--;
}
for(int i = 0; i < B.length; i++) {
int distance = B[i] - pivot;
result[100 + distance]++;
}
for(int i = 0; i < result.length; i++) {
if(result[i] > 0) {
int value = i - 100 + pivot;
System.out.print(value + " ");
}
}
}
}