# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def deleteDuplicates(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if head==None:return None
ans=head
while(head.next!=None):
if head.next.val==head.val:
head.next=head.next.next
else:
head=head.next
return ans
LeetCode-83-Remove Duplicates from Sorted List 链表水题
最新推荐文章于 2023-12-10 17:16:02 发布