You are viewing a single comment's thread. Return to all comments →
N = int(input()) a = set(map(int,input().split())) b = int(input()) for _ in range(b): operation = input().split() #print(operation) otherset = set(map(int,input().split())) #print(otherset) if len(otherset) == int(operation[1]): if operation[0] == "update": a.update(otherset) #print(a) elif operation[0] == "intersection_update": a.intersection_update(otherset) #print(a) elif operation[0] == "difference_update": a.difference_update(otherset) #print(a) elif operation[0] == "symmetric_difference_update": a.symmetric_difference_update(otherset) #print(a) else: print("Plese enter according to the Number") print(sum(a))
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Set Mutations
You are viewing a single comment's thread. Return to all comments →
N = int(input()) a = set(map(int,input().split()))
b = int(input()) for _ in range(b): operation = input().split() #print(operation) otherset = set(map(int,input().split())) #print(otherset) if len(otherset) == int(operation[1]): if operation[0] == "update": a.update(otherset)
#print(a) elif operation[0] == "intersection_update": a.intersection_update(otherset) #print(a) elif operation[0] == "difference_update": a.difference_update(otherset) #print(a) elif operation[0] == "symmetric_difference_update": a.symmetric_difference_update(otherset) #print(a) else: print("Plese enter according to the Number") print(sum(a))