-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMissing Numbers.cpp
53 lines (49 loc) · 988 Bytes
/
Missing Numbers.cpp
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
// Missing Numbers.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n, m;
cin >> n;
vector<int>a(n, 0);
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
cin >> m;
vector<int>b(m, 0);
for (int i = 0; i < m; i++)
{
cin >> b[i];
}
vector<int>::iterator min, max;
min = min_element(b.begin(), b.end());
max = max_element(b.begin(), b.end());
int mi, ma;
mi = *min;
ma = *max;
vector<int>v_a(ma - mi + 1, 0);
vector<int>v_b(ma - mi + 1, 0);
for (int i = 0; i < a.size(); i++)
{
v_a[a[i] - mi]++;
}
for (int i = 0; i < b.size(); i++)
{
v_b[b[i] - mi]++;
}
for (int i = 0; i < (ma-mi); i++)
{
if (v_a[i] != v_b[i])
{
cout << i + mi << " ";
}
}
return 0;
}