Python 隊裡 list的常規操作, pop(0)第一個元素出棧, pop(-1)最後一個元素出棧, remove(3)刪除list中值等於3的元素, insert(index, value),在index的位置,插入value
HJ48 從單向鏈表中刪除指定值的節點
ip = list(map(int,input().split()))
total = ip.pop(0)
head = ip.pop(0)
delete = ip.pop(-1)
idata = ip
res = [head]
for i in range(0,len(idata),2):
value = idata[i]
index = res.index(idata[i+1])+1
res.insert(index, value)
res.remove(delete)
print(*res)