MCPcopy Create free account
hub / github.com/careercup/ctci / deleteNode

Function deleteNode

python/Chapter 2/Question2_3.py:3–11  ·  view source on GitHub ↗
(linkedlist, node)

Source from the content-addressed store, hash-verified

1from classes.LinkedList import *
2
3def deleteNode(linkedlist, node):
4 if node.next != None:
5 node.value = node.next.value
6 node.next = node.next.next
7
8 # if the given node is the last one, no way to delete it.
9 # Here we set the last one's value to None
10 else:
11 node.value = None
12
13
14

Callers 1

Question2_3.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected