Problem:
Write code to remove duplicates from an unsorted linked list
Solution:
Code:
Write code to remove duplicates from an unsorted linked list
Solution:
- Have two pointers ptr1 and ptr2.
- For each node ptr1 visits check from head [head to node before ptr1] whether that data is already present.
- If so, remove the ptr1 node.
- return the new list without any duplicates
Code:
No comments:
Post a Comment