Skip to content

Commit 8aedbcb

Browse files
authored
Create 83-remove_duplicates_from_sorted_list.py
1 parent a8d4678 commit 8aedbcb

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
https://leetcode.com/problems/remove-duplicates-from-sorted-list/
3+
"""
4+
5+
# Definition for singly-linked list.
6+
# class ListNode(object):
7+
# def __init__(self, val=0, next=None):
8+
# self.val = val
9+
# self.next = next
10+
class Solution(object):
11+
def deleteDuplicates(self, head):
12+
"""
13+
:type head: ListNode
14+
:rtype: ListNode
15+
"""
16+
curr = head
17+
18+
while curr and curr.next:
19+
if curr.val == curr.next.val:
20+
curr.next = curr.next.next
21+
else:
22+
curr = curr.next
23+
24+
return head83-

0 commit comments

Comments
 (0)