Remove Duplicates from a Linked Lists




class LinkedList {
constructor(value) {
this.value = value; = null;
function removeDuplicatesFromLinkedList(linkedList) {
let currentNode = linkedList
while (currentNode !== null) {
let nextDistinctNode =
while (nextDistinctNode !== null && nextDistinctNode.value === currentNode.value) {
nextDistinctNode =
} = nextDistinctNode
currentNode = nextDistinctNode
return linkedList;




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Solving LeetCode’s ‘Merge Two Binary Trees’

How to receive Slack notification when somebody sends a Contact form (or any form) — No code — No…

What is Node.js?

5 super reasons to love React JS

The Way — A new Way to Create Node.js Applications

Secure API Authentication with NextJs: Set-Cookie from API

Learn About AJAX in 4 Minutes


Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nerly Ton

Nerly Ton

More from Medium

Bypassing 2K Launcher in Steam for Civilization VI

Hyperbaric Chamber’s Benefits Attracts Pro Skiers to Edwards Colorado

Scaling Joy, Part 2: The Tech Trauma Origin Story

SorareData now uses Opta to provide real-time SO5 scoring & more