Space
Open
From Fieldwork
Scales
Archive
Just... it's straightforward.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def deleteDuplicates(self, head):
current = head
while current and current.next:
if current.val == current.next.val:
# Skip the duplicate node
current.next = current.next.next
else:
# Move forward only when values differ
current = current.next
return headPractice bench
A private scratchpad for this reading. Nothing is sent or scored.
What is still unclear, or what would change the explanation?
Saved on this device · one draft per mode