实在太开心了!!!!!
独立完成第一道链表题!!!!!!
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def deleteDuplicates(self, head: ListNode) -> ListNode: if not head: return p=head q=head.next while q: if p.val==q.val: q=q.next p.next=q else: p=q q=q.next return head
原文:https://www.cnblogs.com/taoyuxin/p/11728762.html