File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Definition for singly-linked list.
3
+ * function ListNode(val) {
4
+ * this.val = val;
5
+ * this.next = null;
6
+ * }
7
+ */
8
+ /**
9
+ * @param {ListNode } head
10
+ * @return {ListNode }
11
+ */
12
+ var deleteDuplicates = function ( head ) {
13
+ const dummy = new ListNode ( - 1 )
14
+ dummy . next = head
15
+ let fast = head
16
+ let slow = head
17
+ while ( slow != null ) {
18
+ while ( fast != null && fast . val === slow . val ) {
19
+ fast = fast . next
20
+ }
21
+ slow . next = fast
22
+ slow = slow . next
23
+ }
24
+ return dummy . next
25
+ } ;
Original file line number Diff line number Diff line change 61
61
- [ 074 Search a 2D Matrix] ( ./074 )
62
62
- [ 075 Sort Colors] ( ./075 )
63
63
- [ 076 Minimum Window Substring] ( ./076 )
64
+ - [ 083 Remove Duplicates from Sorted List] ( ./083 )
64
65
- [ 084 Largest Rectangle in Histogram] ( ./084 )
65
66
- [ 085 Maximal Rectangle] ( ./085 )
66
67
- [ 088 Merge Sorted Array] ( ./088 )
You can’t perform that action at this time.
0 commit comments