How do you remove duplicate nodes from an unsorted linked list?" | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do you remove duplicate nodes from an unsorted linked list?"

11th Jan 2019, 4:54 PM
Mohamed Mikundi
Mohamed Mikundi - avatar
2 Answers
+ 8
Something like this might work: Create a set while iterating over linked list, remove current item if it's in set then add current item to set
11th Jan 2019, 7:24 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 1
Simplest way start at the beginning and check the rest for duplicates to remove. Once done, move to the second and check the rest for duplicates to remove. Repeat until you get to the last where there are none to check.
11th Jan 2019, 6:57 PM
John Wells
John Wells - avatar