Title Description
Input a linked list, the linked list output reciprocal k-th node.
This question my thinking is very simple, is to traverse the list, and then each node push
to a temporary array inside, and finally calculate the reciprocal of the k-th node of index
return can be.
function FindKthToTail(head, k)
{
let values = [];
while(head){
values.push(head);
head = head.next;
}
const index = values.length-k;
return values[index];
}