We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
e = int(input())
e_list = set(list(map(int,input().split())))
op = int(input())
for i in range(0,op):
k, num = input().split()
if (k == 'intersection_update'):
o = set(list(map(int, input().split())))
n = e_list.intersection_update(o)
elif (k == 'symmetric_difference_update'):
o = set(list(map(int, input().split())))
n = e_list.symmetric_difference_update(o)
elif (k == 'difference_update'):
o = set(list(map(int, input().split())))
n = e_list.difference_update(o)
elif (k == 'update'):
o = set(list(map(int, input().split())))
n = e_list.update(o)
print(sum(e_list))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Set Mutations
You are viewing a single comment's thread. Return to all comments →
e = int(input()) e_list = set(list(map(int,input().split()))) op = int(input()) for i in range(0,op): k, num = input().split() if (k == 'intersection_update'): o = set(list(map(int, input().split()))) n = e_list.intersection_update(o) elif (k == 'symmetric_difference_update'): o = set(list(map(int, input().split()))) n = e_list.symmetric_difference_update(o) elif (k == 'difference_update'): o = set(list(map(int, input().split()))) n = e_list.difference_update(o) elif (k == 'update'): o = set(list(map(int, input().split()))) n = e_list.update(o) print(sum(e_list))