Skip to content

Instantly share code, notes, and snippets.

@elowy01
Created October 4, 2021 21:59
Show Gist options
  • Save elowy01/1b83623a7c84529617d824fb341bc685 to your computer and use it in GitHub Desktop.
Save elowy01/1b83623a7c84529617d824fb341bc685 to your computer and use it in GitHub Desktop.
https://www.hackerrank.com/challenges/py-set-discard-remove-pop/problem
Solution:
n = int(input())
s = set(map(int, input().split()))
for _ in range(int(input())):
elms= input().split()
if len(elms)>1:
eval(f"s.{elms[0]}({elms[1]})")
else:
eval(f"s.{elms[0]}()")
print(sum(s))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment