未验证 提交 8f5e73f4 编写于 作者: K KEQI HUANG 提交者: GitHub

Update 083._remove_duplicates_from_sorted_list.md

上级 5dd2f452
......@@ -9,25 +9,20 @@
Easy
dummy 大法
```
```python
class Solution(object):
def deleteDuplicates(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
cur = head
while cur:
if cur.next:
if cur.val == cur.next.val:
cur.next = cur.next.next
else:
cur = cur.next
# cur.next None
else:
break
return head
dummy = head
while head:
while head.next and head.next.val == head.val:
head.next = head.next.next # skip duplicated node
head = head.next # not duplicate of current node, move to next node
return dummy
```
\ No newline at end of file
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册