We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 600e1d9 commit 6d19821Copy full SHA for 6d19821
83-remove-duplicates-from-sorted-list.js
@@ -20,3 +20,31 @@ const deleteDuplicates = function(head) {
20
}
21
return head;
22
};
23
+
24
+// another
25
26
+/**
27
+ * Definition for singly-linked list.
28
+ * function ListNode(val, next) {
29
+ * this.val = (val===undefined ? 0 : val)
30
+ * this.next = (next===undefined ? null : next)
31
+ * }
32
+ */
33
34
+ * @param {ListNode} head
35
+ * @return {ListNode}
36
37
+const deleteDuplicates = function(head) {
38
+ let prev = null, cur = head
39
+ while(cur) {
40
+ if(prev && prev.val === cur.val) {
41
+ prev.next = cur.next
42
+ cur = cur.next
43
+ } else {
44
+ prev = cur
45
46
+ }
47
48
+ return head
49
+};
50
0 commit comments