题解 | #【模板】链表#
【模板】链表
https://www.nowcoder.com/practice/97dc1ac2311046618fd19960041e3c6f
link = []
for i in range(int(input())):
ipt = input().split()
if ipt[0] == 'insert':
x,y = int(ipt[1]),int(ipt[2])
if x in link:
link.insert(link.index(x),y)
else:
link.append(y)
if ipt[0] == 'delete':
x = int(ipt[1])
if x in link:
link.remove(x)
print('NULL') if not link else [print(i,end=' ') for i in link]
#数据结构编程链表#

查看1道真题和解析