Skip to content

Commit 1d9485e

Browse files
committedFeb 3, 2023
Add solution #83
1 parent 7b0f65d commit 1d9485e

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed
 

‎solutions/0083-remove-duplicates-from-sorted-list.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,14 @@
2020
*/
2121
var deleteDuplicates = function(head) {
2222
const result = new ListNode();
23-
const set = new Set();
2423
let tail = result;
2524

2625
while (head) {
27-
if (!set.has(head.val)) {
26+
if (head.val !== head.next?.val) {
2827
tail.next = new ListNode(head.val);
2928
tail = tail.next;
3029
}
31-
32-
set.add(head.val);
33-
30+
previous = head.val;
3431
head = head.next;
3532
}
3633

0 commit comments

Comments
 (0)
Please sign in to comment.