题解 | #从单向链表中删除指定值的节点#
从单向链表中删除指定值的节点
https://www.nowcoder.com/practice/f96cd47e812842269058d483a11ced4f
splice90方法的运用 完整代码如下:
const rl = require("readline").createInterface({ input: process.stdin }); var iter = rl[Symbol.asyncIterator](); const readline = async () => (await iter.next()).value; void async function () { // Write your code here while(line = await readline()){ let arr = line.split(' ').slice(1); let d = arr.pop(); let res = [arr.shift()]; for (let i = 1; i < arr.length; i+=2) { res.splice(res.indexOf(arr[i])+1, 0, arr[i-1]) } res.splice(res.indexOf(d), 1); console.log(res.join(' ')); } }()