We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d829f1b commit 44a9a96Copy full SHA for 44a9a96
83-remove-duplicates-from-sorted-list/83-remove-duplicates-from-sorted-list.js
@@ -0,0 +1,28 @@
1
+/**
2
+ * Definition for singly-linked list.
3
+ * function ListNode(val, next) {
4
+ * this.val = (val===undefined ? 0 : val)
5
+ * this.next = (next===undefined ? null : next)
6
+ * }
7
+ */
8
9
+ * @param {ListNode} head
10
+ * @return {ListNode}
11
12
+var deleteDuplicates = function(head) {
13
+ if(!head) return null;
14
+ let prev = head;
15
+ let current= head.next;
16
+ while(current){
17
+ if(current.val==prev.val){
18
+ prev.next= current.next;
19
+ }else {
20
+ prev= prev.next;
21
+ }
22
+
23
+ current=current.next;
24
25
26
27
+ return head
28
+};
0 commit comments