From 5dce5047644ea40cb13c6a6df12b61e9077bb6a1 Mon Sep 17 00:00:00 2001 From: Deven <63876261+devenperez@users.noreply.github.com> Date: Sun, 28 May 2023 18:59:26 -0400 Subject: [PATCH] Time: 56 ms (33.26%), Space: 16.4 MB (21.31%) - LeetHub --- .../83-remove-duplicates-from-sorted-list.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 83-remove-duplicates-from-sorted-list/83-remove-duplicates-from-sorted-list.py diff --git a/83-remove-duplicates-from-sorted-list/83-remove-duplicates-from-sorted-list.py b/83-remove-duplicates-from-sorted-list/83-remove-duplicates-from-sorted-list.py new file mode 100644 index 0000000..be144f8 --- /dev/null +++ b/83-remove-duplicates-from-sorted-list/83-remove-duplicates-from-sorted-list.py @@ -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 \ No newline at end of file