diff options
Diffstat (limited to 'users/wpcarro/scratch/facebook/delete-node.py')
-rw-r--r-- | users/wpcarro/scratch/facebook/delete-node.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/users/wpcarro/scratch/facebook/delete-node.py b/users/wpcarro/scratch/facebook/delete-node.py new file mode 100644 index 000000000000..4034449ef0cd --- /dev/null +++ b/users/wpcarro/scratch/facebook/delete-node.py @@ -0,0 +1,19 @@ +from linked_list import Node, from_list + +def delete(node): + if not node.next: + node.value = None + else: + node.value = node.next.value + node.next = node.next.next + +one = Node(1) +two = Node(2) +three = Node(3) + +one.next = two +two.next = three + +print(one) +delete(two) +print(one) |