Skip to content

Commit a9fb30c

Browse files
progress?
1 parent 644c239 commit a9fb30c

File tree

1 file changed

+19
-26
lines changed

1 file changed

+19
-26
lines changed

Python/chapter02/2.4 - Partition/camilo_solution_2.4.py

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -81,30 +81,23 @@ def remove_node(self,data):
8181
prev.next = curr.next
8282
curr = None
8383

84-
def merge_link(self,NodesA,NodesB):
85-
86-
while NodesA is not None:
87-
Nodec = Node()
88-
89-
9084
def partition(self,num):
91-
85+
#llist_A and llist_b to be continers
86+
llist_A = linklist()
87+
llist_B = linklist()
88+
head_A = llist_A.head
89+
head_B = llist_B.head
9290
curr= self.head
91+
# Idea: Make two seperate llink and smash them together
9392
while curr is not None:
94-
if(curr.data > num):
95-
smallNodes = self.push(curr.data)
96-
curr = curr.next
93+
if curr.data <= num:
94+
llist_A.push(curr.data)
9795
else:
98-
lagreNodes = self.(curr.data)
99-
curr = curr.next
100-
101-
102-
103-
104-
105-
106-
107-
96+
llist_B.push(curr.data)
97+
while head_B is not None:
98+
llist_A.push(head_B.data)
99+
head_B = head_B.next
100+
llist_A.printList()
108101

109102

110103

@@ -115,15 +108,15 @@ def partition(self,num):
115108

116109

117110
llist = linklist()
118-
llist.push(1)
119-
llist.push(2)
120111
llist.push(3)
121-
llist.push(4)
122112
llist.push(5)
123-
llist.push(6)
113+
llist.push(8)
114+
llist.push(5)
115+
llist.push(10)
116+
llist.push(2)
117+
llist.push(1)
124118
llist.printList()
125119
llist.lenght()
120+
llist.partition(5)
126121

127-
llist.Delete_Middle_Node()# 3 should be removed
128-
llist.printList()
129122
llist.lenght()

0 commit comments

Comments
 (0)