Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Challenge Summary

append(value) which adds a new node with the given value to the end of the list

insertBefore(value, newVal) which add a new node with the given newValue immediately before the first value node

insertAfter(value, newVal) which add a new node with the given newValue immediately after the first value node

kthFromEnd(k) which returns the node’s value that is k from the end of the linked list.

Challenge Description

write functions that can insert a node into a linked list either before, after, or at the end of other nodes in the list.

Write a method for the Linked List class which takes a number, k, as a parameter. Return the node’s value that is k from the end of the linked list.

Approach & Efficiency

time: O(n)

space: O(n)

Solution

whiteboard

kthFromEndWhiteboard