题解 | #从单向链表中删除指定值的节点#
从单向链表中删除指定值的节点
https://www.nowcoder.com/practice/f96cd47e812842269058d483a11ced4f
let line=readline().split(' ') let len=line.shift(), head=line.shift(), tar=line.pop(); let ans=[head],i=0; while(i<line.length){ let t =line[i+1],n=line[i]; let index=ans.indexOf(t) ans.splice(index+1,0,n) i+=2 } let tarIndex=ans.indexOf(tar) ans.splice(tarIndex,1) console.log(ans.join(' '))