Python logical solution


#1

def solve(self, A, B, C):

    dic={}
    for i in set(A):
        if(i in dic):
            dic[i]+=1
        else:
            dic[i]=1
            
    for j in set(B):
        if(j in dic):
            dic[j]+=1
        else:
            dic[j]=1
            
    for k in set(C):
        if(k in dic):
            dic[k]+=1
        else:
            dic[k]=1
            
    A=set(A)
    B=set(B)
    C=set(C)
    ans=[]
    for m in dic:
        if(m in A and m in B and m in C):
            ans.append(m)
            
        elif(m in A and m in B and m not in C):
            ans.append(m)
            
        elif(m in A and m not in B and m in C):
            ans.append(m)
            
        elif(m not in A and m in B and m in C):
            ans.append(m)
            
        else:
            continue
    ans.sort()   
    return(ans)