Why the following code is consider inefficient and how can I improve it? while the code works, in huge n or big a/b it fails to deliver instant results.
what have I tired? I sorted initially n,a and b but no change in performance.
Objective, find the sum of h-m Note: len(a) always equal to len(b)
n=[1, 5, 3] #//can be with 100K+ items
a=set([3,1]) #//can be with 50K+ items
b=set([5,7])
h=0
m=0
for ia, ib in zip(a,b):
if ia in n:
h+=1
if ib in n:
m+=1
print (h-m)