Skip to content

Commit 27ab582

Browse files
committed
083
1 parent 97edcbb commit 27ab582

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

083/main.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
};

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
- [074 Search a 2D Matrix](./074)
6262
- [075 Sort Colors](./075)
6363
- [076 Minimum Window Substring](./076)
64+
- [083 Remove Duplicates from Sorted List](./083)
6465
- [084 Largest Rectangle in Histogram](./084)
6566
- [085 Maximal Rectangle](./085)
6667
- [088 Merge Sorted Array](./088)

0 commit comments

Comments
 (0)