We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Enter your code here. Read input from STDIN. Print output to STDOUT
n, m = map(int, input().split())
arr = list(map(int, input().split()))
a = set(map(int, input().split()))
b = set(map(int, input().split()))
hap=0
for i in arr :
if i in a and i in b:
pass
elif i not in a and i not in b:
pass
elif( i in a and i not in b ):
hap+=1
else:
hap-=1
print (hap)
For future reference: Do not cast the full main list of objects as a set. Using a list is necessary to maintain the integrity of the count, including duplicates.
Python 3
I am not sure why it is in medium level.. I realised it after I got 50 points: I solved it very easily(unsure if i did it correctly as I am new)
Here is my solution:
`
Enter your code here. Read input from STDIN. Print output to STDOUT
n, m = map(int, input().split())
arr = list(map(int, input().split())) a = set(map(int, input().split())) b = set(map(int, input().split())) hap=0 for i in arr : if i in a and i in b: pass elif i not in a and i not in b: pass elif( i in a and i not in b ): hap+=1 else: hap-=1 print (hap)
For future reference: Do not cast the full main list of objects as a set. Using a list is necessary to maintain the integrity of the count, including duplicates.