Answers for "Set .discard(), .remove() & .pop() hackerrank solution"

0

Set .discard(), .remove() & .pop() hackerrank solution

n=int(input())
s=set(map(int,input().split()))
N=int(input())
for i in range(N):
  command=input().split()
  if command[0]=="remove":
  	s.remove(int(command[1]))
  elif command[0]=="discard":
    s.discard(int(command[1]))
  else:
    s.pop()
print(sum(s))
Posted by: Guest on April-29-2020

Code answers related to "Set .discard(), .remove() & .pop() hackerrank solution"

Python Answers by Framework

Browse Popular Code Answers by Language