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.
my code is giving correct ouput. i have checked same sinario in spyder and vs code. there it is working fine. but here i am getting run time issue. i think there is issue from intrepreter of hackerrank.please check.
this is my code:
n=input()
number=input()
s=set(int(x) for x in number.split())
num=int(input())
for i in range(num):
a=list(input().split())
if "pop"in a:
s.pop()
if "discard" in a:
s.discard(int(a[1]))
if "remove" in a:
s.remove(int(a[1]))
print(sum(s))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Set .discard(), .remove() & .pop()
You are viewing a single comment's thread. Return to all comments →
my code is giving correct ouput. i have checked same sinario in spyder and vs code. there it is working fine. but here i am getting run time issue. i think there is issue from intrepreter of hackerrank.please check.
this is my code: n=input() number=input() s=set(int(x) for x in number.split()) num=int(input()) for i in range(num): a=list(input().split()) if "pop"in a: s.pop() if "discard" in a: s.discard(int(a[1])) if "remove" in a: s.remove(int(a[1])) print(sum(s))