Skip to content

Commit

Permalink
- Easy peasy
Browse files Browse the repository at this point in the history
  • Loading branch information
PG-Momik committed Oct 27, 2024
1 parent ec14601 commit 0670d01
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions _014_removeDuplicatesFromSortedList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var deleteDuplicates = function(head) {
if (!head || !head.next) return head;

let current = head;

while (current && current.next) {
if (current.val === current.next.val) {
current.next = current.next.next;
} else {
current = current.next;
}
}

return head;
};

0 comments on commit 0670d01

Please sign in to comment.