
Delete a node from a singly-linked list in O(1) time and O(1) space - hoanhan101
https://www.getrevue.co/profile/hoanhan101/issues/delete-a-node-from-a-singly-linked-list-in-o-1-time-and-o-1-space-8-201165
======
Someone
_”Delete a node from a singly-linked list, given only a pointer to that
node.”_

From the ‘solution’:

    
    
      // if the next node is nil, it's the last node.
      // this implementation does not work.
    

On top of that, the ‘solution’ doesn’t delete the node given; it deletes the
one after it, but copies its value to the node to be deleted. That may be fine
in some cases, but problematic in others, say when other code uses node
addresses to access nodes.

I would change the problem statement to _”_Remove_ a _value_ from a _circular_
singly-linked list, given only a pointer to the node containing the value.”_

~~~
hoanhan101
Thank you for the suggestion.

