function a(head,k) {
let array = [];
if (head === null) {
return false;
}
let node = head;
while(node != null)
{
array.push(node);
node = node.next();
}
return array[array.length - k];
}
原来以为js和链表不是一个世界的,原来还可以这样,js太强大了。
function a(head,k) {
let array = [];
if (head === null) {
return false;
}
let node = head;
while(node != null)
{
array.push(node);
node = node.next();
}
return array[array.length - k];
}
原来以为js和链表不是一个世界的,原来还可以这样,js太强大了。