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.
- Prepare
- Python
- Sets
- Set Mutations
- Discussions
Set Mutations
Set Mutations
Sort by
recency
|
829 Discussions
|
Please Login in order to post a comment
n = int(input()) s = set(map(int,input().split())) its = int(input()) for i in range(its): ops = input().split() opn = ops[0] opt = int(ops[1]) ms = set(map(int,input().split())) if opn == "update": s.update(ms) elif opn == "intersection_update": s.intersection_update(ms) elif opn == "symmetric_difference_update": s.symmetric_difference_update(ms) else: s.difference_update(ms)
print(sum(s))
Here is my code
here you go
logic for this code