You are viewing a single comment's thread. Return to all comments →
Why would this not work:
import sys
def solution(n, values, lines, N): for i in range(N): if lines[i][0] == "d": values.discard(int(lines[i][-1])) elif lines[i][0] == "r": values.remove(int(lines[i][-1])) else: values.pop()
return values
if name=="main": n = int(input()) values = set(map(int, input().split())) N = int(input())
lines = [] for _ in range(N): lines.append(input().strip()) result = solution(n, values, lines, N) print(result)
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 →
Why would this not work:
import sys
def solution(n, values, lines, N): for i in range(N): if lines[i][0] == "d": values.discard(int(lines[i][-1])) elif lines[i][0] == "r": values.remove(int(lines[i][-1])) else: values.pop()
if name=="main": n = int(input()) values = set(map(int, input().split())) N = int(input())