about summary refs log tree commit diff
path: root/scratch/facebook/delete-node.py
diff options
context:
space:
mode:
Diffstat (limited to 'scratch/facebook/delete-node.py')
-rw-r--r--scratch/facebook/delete-node.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/scratch/facebook/delete-node.py b/scratch/facebook/delete-node.py
new file mode 100644
index 000000000000..4034449ef0cd
--- /dev/null
+++ b/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)