Before:[4,5,1,9]
node should be deleted is 5
After:[4,1,9]
Python Code:
class Solution:
def deleteNode(self, node):
temp = node
k = node
while temp.next !=None:
temp.val = temp.next.val
temp = temp.next
if temp.next!=None:
k = k.next
k.next = None
node should be deleted is 5
After:[4,1,9]
Python Code:
class Solution:
def deleteNode(self, node):
temp = node
k = node
while temp.next !=None:
temp.val = temp.next.val
temp = temp.next
if temp.next!=None:
k = k.next
k.next = None
0 Comments