LeetCodeDiary

A Diary for solving LeetCode problems

View on GitHub
'''
Description: 
Autor: Au3C2
Date: 2021-03-26 10:15:47
LastEditors: Au3C2
LastEditTime: 2021-03-26 10:16:01
'''
class Solution:
    def deleteDuplicates(self, head: ListNode) -> ListNode:
        if not head: return
        t = ListNode(None)
        t.next = head
        head = t
        thisNode = head.next
        postNode = thisNode.next
        while postNode:
            while postNode and thisNode.val == postNode.val:
                postNode = postNode.next
            thisNode.next = postNode
            if not postNode:break
            thisNode = postNode
            postNode = postNode.next
        return head.next

# 链表,简单
# https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list/