No Idea!

  • + 1 comment

    Isn't it more efficient to use a for loop? Because sets A and B are disjoint, if you find i in A then you don't need to check it in B. I don't really know list comprehesions, so maybe I'm missing something.

    n, m = input().split()
    array = input().split()
    
    pos = set(input().split())
    neg = set(input().split())
    
    happy = 0
    for a in array:
        if a in pos:
            happy += 1
        elif a in neg:
            happy -= 1
    
    print(happy)