Skip to content

Commit 74ef365

Browse files
committed
simplified loop logic
1 parent 6978def commit 74ef365

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

Python/chapter02/2.1 - Remove Dups/miguel_2.1_sol.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def remove_dups_no_buffer(ll: LinkedList) -> LinkedList:
9898
:return: a linked list without duplicates
9999
"""
100100
n = ll.head
101-
while n.next is not None:
101+
while n is not None:
102102
curr_data = n.data
103103
m = n.next
104104
prev = n
@@ -115,11 +115,6 @@ def remove_dups_no_buffer(ll: LinkedList) -> LinkedList:
115115
prev = m
116116
m = m.next
117117
n = n.next
118-
# if the following is true, this
119-
# means we are at the end of the ll
120-
# and we removed a value at the end
121-
if n is None:
122-
break
123118
return ll
124119

125120

0 commit comments

Comments
 (0)