You are viewing a single comment's thread. Return to all comments →
In C#
public static Node removeDuplicates(Node head) { if(head == null) return null; HashSet<int> dataList = new HashSet<int>(); dataList.Add(head.data); Node orgHead = head; while(head.next != null) { Node tmpNode = head.next; if(!dataList.Add(tmpNode.data)) head.next = head.next.next; else head = head.next; } return orgHead; }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 24: More Linked Lists
You are viewing a single comment's thread. Return to all comments →
In C#