Skip to content

Latest commit

 

History

History

Implement a singly linked list structure

Create a Python class that implements the methods of a list structure.

Challenge

Implement the following methods.

  • insert set a value as the start of the list before other nodes
  • insert_after insert a node with value after the first node containing key
  • insert_before insert a node with value before the first node containing key
  • append set a value as a node at the end of the list
  • remove taking a key and removing the first node that contains the key
  • kth_from_end taking an integer index and returning the node k from end of list
  • has_loop without arguments return if there is a loop in list links

Implement the following functions.

  • merge_lists zip two lists together and return the new head

Solution

Whiteboard Images