Skip to content

Commit fcbd0f2

Browse files
2.4 done?
1 parent cba19dd commit fcbd0f2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def partition(self,num):
8787
list_B = linklist()
8888
curr = self.head
8989
# Idea: Make two seperate llink and smash them together
90+
9091
while curr is not None:
9192
if curr.data <= num:
9293
list_A.push(curr.data)
@@ -97,14 +98,12 @@ def partition(self,num):
9798
list_B.printList()
9899

99100
#Go through all of A the point the end of A to the begining of B
101+
100102
self.head = list_A.head
101103
head_A = list_A.head
102-
while head_A:
103-
if head_A.next is not None:
104-
head_A = head_A.next
105-
106-
head_A.next = list_B.head
104+
while head_A.next:
107105
head_A = head_A.next
106+
head_A.next = list_B.head
108107

109108

110109

0 commit comments

Comments
 (0)