Skip to content

Question

  • Given a linked list and integer n, return the element n spaces from the last node in the list. Do not call the 'size' method of the linked list. Assume that n will always be less than the length of the list.
const list = new List();
list.insertLast('a');
list.insertLast('b');
list.insertLast('c');
list.insertLast('d');
fromLast(list, 2).data // 'b'