解题思路:
每一个检查一下,一直到链表最后就好啦
代码如下:
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def deleteDuplicates(self, head: ListNode) -> ListNode:
p = head
p_aft = head
if p is None or p.next is None:
return p
else:
p_aft == p.next
while p_aft != None:
if p.val == p_aft.val:
p.next = p_aft.next
p_aft = p_aft.next
else:
p = p.next
p_aft = p_aft.next
return head
结果如下:
- THE END -
最后修改:2022年8月16日
russian bet
Wonderful article! We will be linking to this particularly great content on our website. Keep up the great writing. Elisha Geter
bitcoin
Excellent article. I am facing a few of these issues as well.. Dario Durk
freespin
Hi there mates, pleasant article and pleasant arguments commented at this place, I am genuinely enjoying by these. Boyd Mcannally
passwords
There is definately a great deal to find out about this topic. I like all the points you made. Theron Goodwyn
Looking for sex tonight in your area
Dead pent content , thanks for selective information . Boyd Halberstam
sikis
Only wanna input that you have a very decent web site , I enjoy the style it actually stands out. Marcellus Racioppi