Program To Remove Duplicate Elements From Linked List.

Consider example 12->11->3->4->11->1. In the given example it is required to remove the 11. So the list will look like : 12->3->4->1. This is one of my favorite question. As you see its a simple question but tricky because of various edge cases. Consider following scenarios:

list with single element 11

11->23-34

11->11->23->32

23->34->45

23->34->11->11

1->23->11->34

The LinkedList for the example is singly. Here is how Node class looks like: