-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmis.py
More file actions
36 lines (28 loc) · 858 Bytes
/
mis.py
File metadata and controls
36 lines (28 loc) · 858 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
#!/bin/python
# Missing number between 2 arrays - 100 pass
import sys
def missingNumbers(arr, brr):
# Brute force with brr length which is greater
freq = {}
for i in range(len(brr)):
if brr[i] not in freq:
freq[brr[i]] = 1
else:
freq[brr[i]] += 1
if i < len(arr):
if arr[i] not in freq:
freq[arr[i]] = -1
else:
freq[arr[i]] -= 1
result = []
for key, value in freq.items():
if value > 0:
result.append(key)
return result
if __name__ == "__main__":
n = int(raw_input().strip())
arr = map(int, raw_input().strip().split(' '))
m = int(raw_input().strip())
brr = map(int, raw_input().strip().split(' '))
result = missingNumbers(arr, brr)
print " ".join(map(str, result))