Created
November 12, 2018 00:24
-
-
Save AlexeiDarmin/ad38e416697f4c6d2134bafd368806bd to your computer and use it in GitHub Desktop.
Delete a middle node from a singly-linked list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deleteSomeNode(node: Node) { | |
if (!node) { | |
return | |
} | |
if (!node.next) { | |
node = undefined | |
} | |
if (node.next) { | |
node.data = node.next.data | |
node.next = node.next.next | |
} | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment