Skip to content

Commit 352d732

Browse files
committed
Day 6
Remove duplicates from singly linkedlist
1 parent a34c1a8 commit 352d732

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

day_6_remove_duplicates.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Definition for singly-linked list.
2+
# class ListNode:
3+
# def __init__(self, val=0, next=None):
4+
# self.val = val
5+
# self.next = next
6+
class Solution:
7+
def deleteDuplicates(self, head: Optional[ListNode]) -> Optional[ListNode]:
8+
temp = head
9+
while (temp and temp.next):
10+
if (temp.val == temp.next.val):
11+
temp.next = temp.next.next
12+
else:
13+
temp = temp.next
14+
return head

0 commit comments

Comments
 (0)