We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2a57d13 commit 272820aCopy full SHA for 272820a
solution/082.Remove Duplicates from Sorted List II/Solution.py
@@ -0,0 +1,35 @@
1
+# Definition for singly-linked list.
2
+# class ListNode:
3
+# def __init__(self, x):
4
+# self.val = x
5
+# self.next = None
6
+
7
+class Solution:
8
+ def deleteDuplicates(self, head):
9
+ """
10
+ :type head: ListNode
11
+ :rtype: ListNode
12
13
+ if head == None:
14
+ return None
15
+ list0=list()
16
+ i=head
17
+ while i:
18
+ list0.append(i.val)
19
+ i=i.next
20
+ list1=list0.copy()
21
+ for i in list0:
22
+ c=list0.count(i)
23
+ if c != 1:
24
+ while 1:
25
+ try:
26
+ list1.remove(i)
27
+ except:
28
+ break
29
30
+ new_listnode=ListNode(0)
31
+ j=new_listnode
32
+ for v in list1:
33
+ new_listnode.next=ListNode(v)
34
+ new_listnode=new_listnode.next
35
+ return j.next
0 commit comments