This code works time efficiently but if I replace the two lines with comment lines (assigning value to A
and B
), it takes much more time to pass certain test cases.
constraints: n,m in range(10^5)
, any integer in arr is in range(10^9)
Please explain.
n, m = input().split()
arr=list(map(int,input().split()))
A = set(map(int,input().split())) #list(map(int,input().split()))
B = set(map(int,input().split())) #list(map(int,input().split()))
count=0
for i in range(len(arr)):
if arr[i] in A:
count+=1
elif arr[i] in B:
count+=-1
print(count)