Ad
  • Custom User Avatar

    Create a copy of the given linked list, iterate over the copy, and modify each of its nodes according to the given function. Return the modified copy of the list. The original list must remain unmodified.
    P.S. You can't create a copy of a linked list by simply creating a new variable.
    Example in JavaScript:
    const newHead = head; // This won't work! It doesn't create a copy. It creates a reference to the same list.
    You must build a new list, node by node.