Question

Write an algorithm to remove duplicated node from a linked list.

Solution

There are many ways to do it. For the first one, as the simplest one, we could use 2 loops to compare each element with all other elements. However, this takes forever: O(n²).

The second way

Reference

http://www.geeksforgeeks.org/remove-duplicates-from-an-unsorted-linked-list/

Leave a Reply

%d bloggers like this: