-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path2.3
More file actions
27 lines (22 loc) · 622 Bytes
/
2.3
File metadata and controls
27 lines (22 loc) · 622 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#Delete Middle Node
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def push(self, new_data):
new_node = Node(new_data)
new_node.next = self.head
self.head = new_node
return new_node
def printList(self):
current = self.head
while current:
print(current.data)
current = current.next
def DeleteMiddleNode(self, nNode):
if nNode.next:
nNode.data = nNode.next.data
nNode.next = nNode.next.next