mirror of
https://github.com/devenperez/leetcode.git
synced 2026-06-13 03:27:07 +00:00
Time: 56 ms (33.26%), Space: 16.4 MB (21.31%) - LeetHub
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
# 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: Optional[ListNode]) -> Optional[ListNode]:
|
||||
current = head
|
||||
while current != None:
|
||||
next = current.next
|
||||
|
||||
while next != None and current.val == next.val:
|
||||
next = next.next
|
||||
|
||||
|
||||
current.next = next
|
||||
current = next
|
||||
|
||||
return head
|
||||
Reference in New Issue
Block a user