Python practice - not to identify common elements of two arrays

Python practice - not to identify common elements of two arrays

Given two integer array, this question is not asked to identify elements common to both.

Input formats:

Two input lines are given in two integer array, each of the first row is given a positive integer N (≦ 20), followed by N integers, separated by a space therebetween.

Output formats:

Output in a row in numerical order is not given a total of two array elements, separated by a space between the numbers, but the end of the line can not be redundant space. Title ensure that there is at least one such number. Not repeat the same digital output.

Sample input:

10 3 -5 2 8 0 3 5 -15 9 100
11 6 4 8 2 6 -5 9 0 100 8 1

Sample output:

3 5 -15 6 4 1

a1 = list(map(str,input().split()))
b1 = list(map(str,input().split()))
a = a1[1:]
b = b1[1:]
s = []
for i in a:
    if i not in b and i not in s:
        s.append(i)
for i in b:
    if i not in a and i not in s:
        s.append(i)
print(" ".join(s))
Published 175 original articles · won praise 7 · views 9052

Guess you like

Origin blog.csdn.net/linjiayina/article/details/104400845