Coding Kata – January 28 2010 – Crazy List Copying

1.28.2010 | Kata

Goal: Create a duplicate copy of a linked list given the following facts about the linked list:

  • Each node in the list has a pointer to the next element in the list, or null if no element is present
  • Each node in the list has a data pointer which points to any arbitrary node in the list

Constraints:

  • You are allowed to modify the list, so long as it is returned to its original state

Example:

Hmmm of the day: Can this be solved using pointer arithmetic, and if so, is it the most efficient solution?


Comments