Skip to content

Commit 6a3c05a

Browse files
authored
Update linked_list.md
1 parent 5b91fcb commit 6a3c05a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

data_structure/linked_list.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,13 @@ class Solution:
9696
```Python
9797
class Solution:
9898
def deleteDuplicates(self, head: ListNode) -> ListNode:
99-
dummy = ListNode()
100-
dummy.next = head
99+
dummy = ListNode(0, head)
101100
pre = dummy
102101
while head:
103102
cur = head.val
104103
if head.next and cur == head.next.val:
105-
while head.next and cur == head.next.val:
104+
while head and cur == head.val:
106105
head = head.next
107-
head = head.next
108106
pre.next = head
109107
else:
110108
pre = head

0 commit comments

Comments
 (0)