📜  设置 .discard()、.remove() 和 .pop() | Hackerrank Python 解决方案 | - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:16.880000             🧑  作者: Mango

代码示例1
num = int(input())
data = set(map(int, input().split()))
operations = int(input())

for x in range(operations):
  oper = input().split()
  if oper[0] == "remove":
    data.remove(int(oper[1]))
  elif oper[0] == "discard":
    data.discard(int(oper[1]))
  else:
    data.pop()
    
print(sum(data))