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.

  • Custom User Avatar

    I still think it is a kata issue, the original list should not be mutated should be a requirement then :/

  • Custom User Avatar

    Same issue here. Can you explain better why list shouldn't be mutated in this test when function is x=>x+1 (which obiously mutates the result)?

  • Custom User Avatar

    The function is ok, that test it's not testing the output value, it's testing the input before and after your function is called.

  • Custom User Avatar

    Not a kata issue, you've mutated the list

    Make sure you do not modify the original list!