Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
  • Loading branch information
imteekay committed Dec 13, 2023
1 parent 04781b1 commit e34d1ed
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function removeDuplicatesFromLinkedList(linkedList) {
let head = linkedList;
while (linkedList) {
let next = linkedList.next;
while (next && linkedList.value === next.value) {
next = next.next;
}
linkedList.next = next;
linkedList = next;
}
return head;
}

0 comments on commit e34d1ed

Please sign in to comment.