We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6b0fd59 commit 86e012aCopy full SHA for 86e012a
1 file changed
practice/linked_list.py
@@ -32,6 +32,20 @@ def traverse(self):
32
print temp.key
33
temp = temp.next
34
35
+ def pop_key(self, key):
36
+ temp = self.head.next
37
+ prev = self.head
38
+ if prev.key == key:
39
+ self.pop()
40
+ while temp!=None:
41
+ if temp.key == key:
42
+ print "\n Deleted: ",key
43
+ prev.next = temp.next
44
+ temp = None
45
+ return
46
+ prev = temp
47
+ temp = temp.next
48
+
49
list_ = LinkedList()
50
list_.push(2)
51
list_.push(5)
@@ -48,5 +62,10 @@ def traverse(self):
62
list_.pop()
63
print "\n"
64
list_.traverse()
65
+list_.pop_key(6)
66
+print "\n"
67
+list_.traverse()
68
69
70
52
71
0 commit comments