-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMissing_Numbers.cpp
More file actions
39 lines (36 loc) · 939 Bytes
/
Missing_Numbers.cpp
File metadata and controls
39 lines (36 loc) · 939 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
35
36
37
38
39
/**
* Title : Missing_Numbers.cpp
* Author : Tridib Samanta
* Created : 05-11-2019
* Link : https://www.hackerrank.com/challenges/missing-numbers/problem
**/
#include <iostream>
using namespace std;
int main() {
int frequency[100001];
for(int i = 1; i <= 100000; i++) {
frequency[i] = 0;
}
int n, m;
cin>>n;
// Count no. of appearances of a particular no. in list 1
for(int i = 0; i < n; i++) {
int tmp;
cin>>tmp;
frequency[tmp]++;
}
cin>>m;
// Subtract no. of appearances of a particular no. in list 2
for(int i = 0; i < m; i++) {
int tmp;
cin>>tmp;
frequency[tmp]--;
}
// Any frequency[i] != 0 does not appear the same number of times in each list
for(int i = 1; i <= 10000; i++) {
if(frequency[i] != 0) {
cout<<i<<" ";
}
}
return 0;
}